diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-31 22:56:25 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-31 22:56:25 -0700 |
commit | 9d9da2adf96d783ae51edc1bf6c9cbe6017ead8f (patch) | |
tree | 8e34d2dbc40041a06cc44110a3973aed90f40e55 /022arithmetic.cc | |
parent | 1167f8779c2de268a074fc8656f022721df56c3f (diff) | |
download | mu-9d9da2adf96d783ae51edc1bf6c9cbe6017ead8f.tar.gz |
3618
Diffstat (limited to '022arithmetic.cc')
-rw-r--r-- | 022arithmetic.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/022arithmetic.cc b/022arithmetic.cc index f46666f1..23f9a39d 100644 --- a/022arithmetic.cc +++ b/022arithmetic.cc @@ -269,8 +269,9 @@ case DIVIDE_WITH_REMAINDER: { :(before "End Primitive Recipe Implementations") case DIVIDE_WITH_REMAINDER: { products.resize(2); - int a = static_cast<int>(ingredients.at(0).at(0)); - int b = static_cast<int>(ingredients.at(1).at(0)); + // fractions will be dropped; very large numbers will overflow + long long int a = static_cast<long long int>(ingredients.at(0).at(0)); + long long int b = static_cast<long long int>(ingredients.at(1).at(0)); if (b == 0) { raise << maybe(current_recipe_name()) << "divide by zero in '" << to_original_string(current_instruction()) << "'\n" << end(); products.resize(2); @@ -278,11 +279,10 @@ case DIVIDE_WITH_REMAINDER: { products.at(1).push_back(0); break; } - int quotient = a / b; - int remainder = a % b; - // very large integers will lose precision - products.at(0).push_back(quotient); - products.at(1).push_back(remainder); + long long int quotient = a / b; + long long int remainder = a % b; + products.at(0).push_back(static_cast<double>(quotient)); + products.at(1).push_back(static_cast<double>(remainder)); break; } |