[comp.lang.ada] Getting the integer part of a real

desj@brahms (David desJardins) (11/11/86)

In article <996@wayback.UUCP> arny@wayback.UUCP (Arny B. Engelson) writes:
>The above algorithm only works for POSITIVE values of X!  For example, if
>X = -0.7 this will return -1 instead of 0.  The "integer part of a real
>number" is a truncate function:

   Not to restart the flame wars (I hope!), but when this topic has been
discussed in the past, the consensus (at least among mathematicians) has
been that "round-down" is preferable to "round-toward-zero."  At the very
least it is not clear that the latter is preferable.

   -- David desJardins

emery@MITRE-BEDFORD.ARPA (Hazel) (11/12/86)

Oops, you got me!  OK, first check if the number is positive or negative, and
do the 'correct' thing.  Obviously, I hadn't thought it all through when
I posted that.  The context of our discussion (at Siemens) on that was 
1.  realizing what the language said, and
2.  coming up with a strategy to get the integer part that didn't depend on
    underlying implementation.  
"The details are left to the reader"  (Meaning, I'm too lazy to work them 
out.  

Thanks, Ken.

				Dave Emery