User Tools

Site Tools


numeric

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
numeric [2025/02/27 21:06] – inverse, not xor. carlnumeric [2026/03/14 21:01] (current) carl
Line 36: Line 36:
 As a consequence of their representation, most operations on numeric types are not true to their eponymous  mathematical function.  For example, adding two Int32 numbers can overflow, resulting in a wrong answer.  Also, most floating point operations are not associative: (a + b) + c != a + (b + c).  This is usually uncommon enough that it isn't a problem, but care should be taken to programming defensively.   As a consequence of their representation, most operations on numeric types are not true to their eponymous  mathematical function.  For example, adding two Int32 numbers can overflow, resulting in a wrong answer.  Also, most floating point operations are not associative: (a + b) + c != a + (b + c).  This is usually uncommon enough that it isn't a problem, but care should be taken to programming defensively.  
  
 +
 +
 +===== Support in Languages =====
 +
 +==== Java ====
 +Main: [[java:numeric|Java Numeric]].
 +
 +
 +
 +===== Numeric Observations =====
 +
 +When dividing two quantities, the quotient and the remainder have different units.   For example, 10 apples divided by 3 apples is 3, but the remainder is 1 apple.  Note that the quotient unit changed.
 +
 +The units may be different too.  Consider calculating the quotient and remainder of 10 meters in 3 seconds.
 +
 +A = 10 meters
 +
 +B = 3 seconds
 +
 +Q = floor(A / B)
 +
 +R = A % B
 +
 +This maintains the identity A = Q * B + R.  Thus:
 +
 +Q = 3 meters/second
 +
 +R = 1 meter
 +
 +
 +
 +
 +===== Taylor Series =====
 +The Taylor Series for the exponential function diverges quickly if less than 100 terms are used.  These terms tend to have enormous numerators and denominators.   The numerator is usually x^100, and the denominator is 100!.   Floating point math is not suited to represent these values as the number of terms exceeds 100ish.
  
numeric.1740690391.txt.gz · Last modified: by carl