From 9d9da2adf96d783ae51edc1bf6c9cbe6017ead8f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 31 Oct 2016 22:56:25 -0700 Subject: 3618 --- html/022arithmetic.cc.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'html/022arithmetic.cc.html') diff --git a/html/022arithmetic.cc.html b/html/022arithmetic.cc.html index 7a0e24b9..4d2b454e 100644 --- a/html/022arithmetic.cc.html +++ b/html/022arithmetic.cc.html @@ -305,8 +305,9 @@ put(Recipe_ordinal,:(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); @@ -314,11 +315,10 @@ put(Recipe_ordinal,.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; } -- cgit 1.4.1-2-gfad0