From 6bd500c34bcaccc84558982cf9821dce8c025834 Mon Sep 17 00:00:00 2001 From: slava Date: Sat, 16 Sep 2006 19:57:07 +0000 Subject: [PATCH] Document division by zero behavior --- TODO.FACTOR.txt | 10 +++++----- doc/handbook/math.facts | 9 ++++++++- library/math/math.facts | 14 ++++++-------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 25b635f682..e325e8f796 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -15,6 +15,7 @@ - track individual method usages - variable width word wrap - add-gadget, model-changed, set-model should compile +- set-model set-model* and control-changed: its a hack, clean it up - graphical module manager tool - editor: - more efficient multi-line inserts @@ -22,17 +23,16 @@ space - we have trouble drawing rectangles - ui browser: show currently selected vocab & words - +- the editor should fill up the interior of the scroller completely - doc sweep - tool help - perhaps commands window should sort by gesture - merge keyboard help with help in some way - keyboard help: hide commands whose gestures are shadowed -- division by zero may not raise an error -- document this -- the editor should fill up the interior of the scroller completely + ui: +- help tool: edit, reload buttons - words: - S+left: reload - S+right: inspect @@ -46,7 +46,6 @@ - page scrolling should be timer-based too - invoking interactor commands when interactor is busy -- still fucked because of grafting and ungrafting -- set-model set-model* and control-changed: its a hack, clean it up - x11: scroll up/down wiggles caret - roundoff is still not quite right with tracks - fix top level window positioning @@ -78,7 +77,8 @@ - horizontal wheel scrolling - polish OS X menu bar code - structure editor -- mouse over for input: +- mouse over for input w/ multiple lines looks stupid + + module system: - convention for main entry point of a module diff --git a/doc/handbook/math.facts b/doc/handbook/math.facts index 5600ce70bf..1dec257f1f 100644 --- a/doc/handbook/math.facts +++ b/doc/handbook/math.facts @@ -17,6 +17,13 @@ ARTICLE: "number-types" "Types of numbers" { $subsection "floats" } { $subsection "complex-numbers" } ; +ARTICLE: "division-by-zero" "Division by zero" +"Floating point division never raises an error if the denominator is zero. This means that if at least one of the two inputs to " { $link / } ", " { $link /f } " or " { $link mod } " is a float, the result will be a floating point infinity or not a number value." +$terpri +"The behavior of integer division is hardware specific. On x86 processors, " { $link /i } " and " { $link mod } " raise an error if both inputs are integers and the denominator is zero. On PowerPC, integer division by zero yields a result of zero." +$terpri +"On the other hand, the " { $link / } " word, when given integer arguments, implements a much more expensive division algorithm which always yields an exact rational answer, and this word always tests for division by zero explicitly." ; + ARTICLE: "number-protocol" "Number protocol" "Math operations obey certain numerical upgrade rules. If one of the inputs is a bignum and the other is a fixnum, the latter is first coerced to a bignum; if one of the inputs is a float, the other is coerced to a float." $terpri @@ -29,7 +36,7 @@ $terpri { $subsection * } { $subsection / } "Non-commutative operations take operands from the stack in the natural order; " { $snippet "6 2 /" } " divides 6 by 2." -$terpri +{ $subsection "division-by-zero" } "Real numbers (but not complex numbers) can be ordered:" { $subsection < } { $subsection <= } diff --git a/library/math/math.facts b/library/math/math.facts index 5d56529258..4ad26b6528 100644 --- a/library/math/math.facts +++ b/library/math/math.facts @@ -68,7 +68,7 @@ HELP: / "Division of ratios and complex numbers proceeds using the relevant mathematical rules." } } -{ $errors "Throws an error if both inputs are integers, and the denominator is 0." } ; +{ $see-also "division-by-zero" } ; HELP: /i { $values { "x" "a real number" } { "y" "a real number" } { "z" "a real number" } } @@ -81,7 +81,7 @@ HELP: /i "Integer division of ratios and complex numbers proceeds using the relevant mathematical rules." } } -{ $errors "Throws an error if both inputs are integers, and the denominator is 0." } ; +{ $see-also "division-by-zero" } ; HELP: /f { $values { "x" "a real number" } { "y" "a real number" } { "z" "a real number" } } @@ -94,7 +94,7 @@ HELP: /f "Integer division of ratios and complex numbers proceeds using the relevant mathematical rules." } } -{ $errors "Throws an error if both inputs are integers, and the denominator is 0." } ; +{ $see-also "division-by-zero" } ; HELP: mod { $values { "x" "an integer" } { "y" "an integer" } { "z" "an integer" } } @@ -105,8 +105,7 @@ HELP: mod "Modulus of bignums always yields a bignum." } } -{ $errors "Throws an error if the denominator is 0." } -{ $see-also rem } ; +{ $see-also "division-by-zero" rem } ; HELP: /mod { $values { "x" "an integer" } { "y" "an integer" } { "z" "an integer" } { "w" "an integer" } } @@ -117,7 +116,7 @@ HELP: /mod "The quotient and remainder of two bignums is always a bignum." } } -{ $errors "Throws an error if the denominator is 0." } ; +{ $see-also "division-by-zero" } ; HELP: bitand { $values { "x" "an integer" } { "y" "an integer" } { "z" "an integer" } } @@ -225,8 +224,7 @@ HELP: rem "Modulus of bignums always yields a bignum." } } -{ $errors "Throws an error if the denominator is 0." } -{ $see-also mod } ; +{ $see-also "division-by-zero" mod } ; HELP: sgn { $values { "x" "a real number" } { "n" "-1, 0 or 1" } }