On 1/19/2019 10:37 PM, David Storrs wrote:
On Fri, Jan 18, 2019, 6:36 PM George Neuner <gneun...@comcast.net
<mailto:gneun...@comcast.net> wrote:
witness the legions of newbies every
year who don't understand that computer arithmetic differs from
the math
they were taught in school.
Does it? Bit of a philosophical question, it seems. I mean, so long as
you stick with integers, if you start with the same numbers and run
them through the same operations then you will end up with the same
results regardless of whether you did it on paper or in a computer.
Things get a little weird once you start going into floating point,
but I contend that that's a difference in
implementation/representation, not in math.
As Ellen already mentioned, fixed width integers - although exact values
- have computational properties that are not shared with mathematical
integers. As soon as the computation overflows, all bets are off ...
any number of mathematical invariants may no longer hold.
The troubles with floating point are caused by the representation, but
they aren't limited by it. FP numbers are not simply "limited
precision" approximations of real numbers, but actually are a fuzzy
range that only contains the "limited precision" approximation, and you
don't know where within that range the actual value lies.
FP math bears little resemblance to real math:
* FP numbers are neither associative nor distributive
* even simple invariants like (A+B)-B = A or A+A = 2*A may not hold
* FP numbers don't necessarily have a multiplicative inverse: not all
A have a B= 1/A such that A*B = 1
* FP numbers are not continuous: e.g., B > 0 doesn't mean A+B > A
and there is plenty more. The so-called BigFloat implementations don't
change these properties - they simply push them out further away from
the programmer [who still can be bitten by problems].
There are any number of good references available, but here are a few
[increasing in technicality] to get you started.
[1]
http://www.phys.uconn.edu/~rozman/Courses/P2200_15F/downloads/floating-point-guide-2015-10-15.pdf
[2] http://people.ds.cam.ac.uk/nmm1/Arithmetic/index.html
[3] https://www.itu.dk/~sestoft/bachelor/IEEE754_article.pdf
George
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.