diff options
Diffstat (limited to 'html')
-rw-r--r-- | html/022arithmetic.cc.html | 14 | ||||
-rw-r--r-- | html/070table.mu.html | 4 |
2 files changed, 9 insertions, 9 deletions
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<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> DIVIDE_WITH_REMAINDER: <span class="Delimiter">{</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> - <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> - <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Comment">// fractions will be dropped; very large numbers will overflow</span> + <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> a = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> + <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> b = <span class="Normal">static_cast</span><<span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span>><span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> <span class="Normal">if</span> <span class="Delimiter">(</span>b == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"divide by zero in '"</span> << to_original_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> @@ -314,11 +315,10 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - <span class="Normal">int</span> quotient = a / b<span class="Delimiter">;</span> - <span class="Normal">int</span> remainder = a % b<span class="Delimiter">;</span> - <span class="Comment">// very large integers will lose precision</span> - products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>quotient<span class="Delimiter">);</span> - products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>remainder<span class="Delimiter">);</span> + <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> quotient = a / b<span class="Delimiter">;</span> + <span class="Normal">long</span> <span class="Normal">long</span> <span class="Normal">int</span> remainder = a % b<span class="Delimiter">;</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">double</span>><span class="Delimiter">(</span>quotient<span class="Delimiter">));</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Normal">static_cast</span><<span class="Normal">double</span>><span class="Delimiter">(</span>remainder<span class="Delimiter">));</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/070table.mu.html b/html/070table.mu.html index 7d46ec53..b843f50f 100644 --- a/html/070table.mu.html +++ b/html/070table.mu.html @@ -86,7 +86,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color hash <span class="Special"><-</span> abs hash capacity:num <span class="Special"><-</span> get *table, <span class="Constant">capacity:offset</span> _, hash-key:num <span class="Special"><-</span> divide-with-remainder hash, capacity - hash-key <span class="Special"><-</span> abs hash-key <span class="Comment"># in case hash-key overflows into a negative integer</span> + hash-key <span class="Special"><-</span> abs hash-key <span class="Comment"># in case hash overflows from a double into a negative integer inside 'divide-with-remainder' above</span> table-data:&:@:table-row:_key:_value <span class="Special"><-</span> get *table, <span class="Constant">data:offset</span> x:table-row:_key:_value <span class="Special"><-</span> index *table-data, hash-key occupied?:bool <span class="Special"><-</span> get x, <span class="Constant">occupied?:offset</span> @@ -103,7 +103,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color hash <span class="Special"><-</span> abs hash capacity:num <span class="Special"><-</span> get *table, <span class="Constant">capacity:offset</span> _, hash-key:num <span class="Special"><-</span> divide-with-remainder hash, capacity - hash-key <span class="Special"><-</span> abs hash-key <span class="Comment"># in case hash-key overflows into a negative integer</span> + hash-key <span class="Special"><-</span> abs hash-key <span class="Comment"># in case hash overflows from a double into a negative integer inside 'divide-with-remainder' above</span> table-data:&:@:table-row:_key:_value <span class="Special"><-</span> get *table, <span class="Constant">data:offset</span> x:table-row:_key:_value <span class="Special"><-</span> index *table-data, hash-key occupied?:bool <span class="Special"><-</span> get x, <span class="Constant">occupied?:offset</span> |