# Math (division)

### [1/3] from: ammoncooke::yahoo::com at: 30-May-2001 19:38

I know there is a way to tell is a number is non-decimal, I just don't know the way!
;)) Could someone please help me??
Your help is appreciated.
Ammon

### [2/3] from: larry:ecotope at: 30-May-2001 19:38

Hi Ammon
If you just want to know if it is a REBOL integer:
integer? x
If you want to know if a number has no digits after the decimal place (i.e.,
it is an integer in the mathematical sense), regardless of its REBOL type:

>> math-int: func [x [number!]][x // 1 = 0]
>> math-int pi

== false

>> x: to-decimal 2

== 2

>> type? x

== decimal!

>> math-int x

== true

>> type? 2 ** 52

== decimal!

>> math-int 2 ** 52

== true

>> math-int -2 ** 52

== true
HTH
-Larry
----- Original Message -----
From: "Ammon Cooke" <

**[ammoncooke--yahoo--com]**> To: <**[rebol-list--rebol--com]**> Sent: Wednesday, May 30, 2001 4:38 AM Subject: [REBOL] Math (division) I know there is a way to tell is a number is non-decimal, I just don't know the way! ;)) Could someone please help me?? Your help is appreciated. Ammon### [3/3] from: larry:ecotope at: 30-May-2001 21:34

Hi all
Actually there is a flaw in the implementation of the REBOL comparison
operators (=, >=, <=, equal?, greater?, lesser?, etc.) when applied to the
decimal! type. To be sure the math-int function works correctly for ALL
cases, it should be changed to:
math-int: func [x [number!]][ zero? x // 1]
An example of the problem:

>> math-int 1e-20

== false
which is correct. The function below using equal will return true which is
not correct. One manifestation of the flaw is:

>> 0 = 1e-20

== true

>> positive? 1e-20 - 0

== true

>> zero? 1e-20

== false

>>

The functions zero? positive? and negative? work correctly for the decimal!
type, but = gives an incorrect answer.
-Larry
----- Original Message -----
From: "Larry Palmiter" <

**[larry--ecotope--com]**> To: <**[rebol-list--rebol--com]**> Sent: Wednesday, May 30, 2001 7:38 PM Subject: [REBOL] Re: Math (division) Hi Ammon If you just want to know if it is a REBOL integer: integer? x If you want to know if a number has no digits after the decimal place (i.e., it is an integer in the mathematical sense), regardless of its REBOL type:>> math-int: func [x [number!]][x // 1 = 0]
>> math-int pi

== false

>> x: to-decimal 2

== 2

>> type? x

== decimal!

>> math-int x

== true

>> type? 2 ** 52

== decimal!

>> math-int 2 ** 52

== true

>> math-int -2 ** 52

== true
HTH
-Larry