diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-12 18:08:47 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-12 18:08:47 -0700 |
commit | fca0ebbe0cc01d37e47822d8a62ea062a845f33d (patch) | |
tree | 557ef7d0bd5d3ddc98ab47cf0273c99cc4a09630 /032array.cc | |
parent | 98f3a94201df11501d417ac2e75a756ab54ac873 (diff) | |
download | mu-fca0ebbe0cc01d37e47822d8a62ea062a845f33d.tar.gz |
1360 - store doubles in memory
This is a far cleaner way to provide *some* floating-point support. We can only represent signed integers up to 2^51 rather than 2^63. But in exchange we don't have to worry about it elsewhere, and it's probably faster than checking tag bits in every operation. Hmm, yeah, surprised how easy this was. I think I'll give up on the other approach. I still don't have non-integer literals. But we won't bother with those until we need them. `3.14159:literal` seems ugly.
Diffstat (limited to '032array.cc')
-rw-r--r-- | 032array.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/032array.cc b/032array.cc index 67b03293..04234d3a 100644 --- a/032array.cc +++ b/032array.cc @@ -47,7 +47,7 @@ recipe main [ +mem: storing 16 in location 9 //: disable the size mismatch check since the destination array need not be initialized -:(replace "if (size_of(x) != data.size())" following "void write_memory(reagent x, vector<long long int> data)") +:(replace "if (size_of(x) != data.size())" following "void write_memory(reagent x, vector<double> data)") if (x.types.at(0) != Type_number["array"] && size_of(x) != data.size()) :(after "size_t size_of(const reagent& r)") if (r.types.at(0) == Type_number["array"]) { @@ -102,7 +102,7 @@ case INDEX: { assert(base.types.at(0) == Type_number["array"]); reagent offset = canonize(current_instruction().ingredients.at(1)); //? trace("run") << "ingredient 1 after canonize: " << offset.to_string(); //? 1 - vector<long long int> offset_val(read_memory(offset)); + vector<double> offset_val(read_memory(offset)); vector<type_number> element_type = array_element(base.types); //? trace("run") << "offset: " << offset_val.at(0); //? 1 //? trace("run") << "size of elements: " << size_of(element_type); //? 1 @@ -156,7 +156,7 @@ case INDEX_ADDRESS: { index_t base_address = base.value; assert(base.types.at(0) == Type_number["array"]); reagent offset = canonize(current_instruction().ingredients.at(1)); - vector<long long int> offset_val(read_memory(offset)); + vector<double> offset_val(read_memory(offset)); vector<type_number> element_type = array_element(base.types); index_t result = base_address + 1 + offset_val.at(0)*size_of(element_type); products.resize(1); |