Integer division with / - request explanation of behavior

On Sep 30, 2006, at 2:21 PM, David V. wrote:

Your example works because integers are rational IEEE floating point
numbers. Problems arise when you use a number that’s a rational
decimal
number, but an irrational IEEE binary floating point one. Those aren’t
precise no matter what storage size you use.

I understand what you’re trying to say, but ‘rational’ and
‘irrational’ are the wrong terms. 0.2 = 2/10, therefore it’s a
rational number (it can be expressed exactly as a ratio), but it
can’t be represented exactly as a base 2 floating-point number.
Whether a number is rational (like 0.2) or irrational (like sqrt(3))
is a basic mathematical property of the number; it has nothing to do
with how it’s represented.

TomP

Jeremy T. [email protected] writes:

Not exactly. The result is expressed in the type of the more
precise of the
two operands.

Actually, integers are more precise than IEEE floating points
since 2.2 - 1.2 != 1.0 :slight_smile: s/precise/accurate !

Not on all platforms. For instance, in Ocaml, it’s true:

2. -. 1. = 1.;;

  • : bool = true

No, it doesnt.

Darwin lilith 7.9.0
Objective Caml version 3.08.3

2.2 -. 1.2 = 1.0;;

  • : bool = false

Due to how IEEE floats work, all operations on whole numbers will
always be exact.

On 9/30/06, M. Edward (Ed) Borasky [email protected] wrote:

Robert D. wrote:

Would you mind if I suggest this Ruby Q.

compute all didgits of Pi, if you have less time, just compute the
last
digit of Pi.

Easy as pi … just use the Ruby language “call with continued fraction”
feature.

I fail to understand, why use fractions Pi is defined as 42 of course.
8-]


Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.

  • Albert Einstein