At 6:40 PM +0900 7/19/01, Fumio Nonaka wrote:
>?I am afraid that I do not think so.
>
>myFloat = 7.5
>put ilk(myFloat)
>-- #float
>if not (myFloat mod 2) then put "even"
>-- "even"
>
>The mod function seems to round a float number before evaluation.
Thanks Fumio for the additional information.
(
I am afraid that I do not think so.
myFloat = 7.5
put ilk(myFloat)
-- #float
if not (myFloat mod 2) then put "even"
-- "even"
The mod function seems to round a float number before evaluation.
_
Buzz Kettles wrote:
>
> Did you try the mod function? It can accept floats as well as integers.
>
Thank you, Buzz! You're right.
We did try the mod function, but it failed on floats in D6.
Appearently this is fixed in D8. The project will be moved to director 8, soon.
D6.5:
-
set f = 1144608783851.0
put f/2
-- 572304391925.5000 -- (big odd number)
put f mod 2
-- 0
D8:
---
f = 114460
Did you try the mod function? It can accept floats as well as integers.
(it throws away the non-integer part & then evaluates)
i.e.
myFloat = 7.3
put ilk(myFloat)
-- #float
if (myFloat mod 2) then put "not even"
-- "not even" -- ( 7 is an odd number )
hth
-Buzz
At 9:56 AM -0400 7/17/01, Cole
I appreciate all the good suggestions! Especially liked Roy's method
of paring down the float with the maxinteger.
>it's not cheating if it works.
>- -bh
I couldn't aggree more!
We've actually decided to change the datastructure to use multiple
integers, instead of a great big float. We can g
ainder... if that is the case you only need to check if the last digit in
> >the number is even or zero. If it is you know the number is divisible by 2.
> >
> >HTH
> >
> >Jorge
> >
> >- -Original Message-
> >From: [EMAIL PROTECTED] [mailto:[
From: Roy C. Crisman
on isEvenlyDivisible thisNumber, thisDivisor
if voidP(thisDivisor) then
thisDivisor = 2
end if
thisNumber = float(thisNumber) / thisDivisor
repeat while (thisNumber > the maxInteger)
thisNumber = thisNumber - the maxInteger
end repeat
return (thisNumbe
o. If it is you know the number is divisible by 2.
>
>HTH
>
>Jorge
>
>- -Original Message-
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
>Behalf Of Cole Tierney
>Sent: Tuesday, July 17, 2001 8:57 AM
>To: [EMAIL PROTECTED]
>Subject: Re: Finding If a _huge_
HTH
Jorge
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of R. Bhakti Klein
Sent: Tuesday, July 17, 2001 12:31 PM
To: [EMAIL PROTECTED]
Subject: Re: Finding If a _huge_ float is divisible by a
number
which means that if there's anything to the ri
e Tierney
> Sent: Tuesday, July 17, 2001 8:57 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Finding If a _huge_ float is divisible by a
> number
>
> What a coincedence. A coworker of mine just asked me a similar
> question. In this case we have a huge float (greater than maxint
EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Cole Tierney
Sent: Tuesday, July 17, 2001 8:57 AM
To: [EMAIL PROTECTED]
Subject: Re: Finding If a _huge_ float is divisible by a
number
What a coincedence. A coworker of mine just asked me a similar
question. In this case we have a huge floa
What a coincedence. A coworker of mine just asked me a similar
question. In this case we have a huge float (greater than maxinteger)
and need to know if it is evenly divisable by 2. We can not truncate
the result, since it won't fit into an integer. We'll probably fall
back on converting to a
12 matches
Mail list logo