Velocity Reviews > how can i verify if a number has mantissa???

# how can i verify if a number has mantissa???

fzmaster
Guest
Posts: n/a

 11-25-2005
Actually i need to know how to detect if a number is a perfect square.
But i'v been thinking..
if i sqrt(x) and check if this result has mantissa... so it is not a
interger...and surely not a perfect square.

Well my question is... how can i verify if a number has mantissa???

i'm thx full for R help.
bye.
fzmaster
UNIVERSIDADE FEDERAL DO ESPIRITO SANTO - UFES
BRASIL

Gordon Burditt
Guest
Posts: n/a

 11-25-2005
>Actually i need to know how to detect if a number is a perfect square.
>But i'v been thinking..
>if i sqrt(x) and check if this result has mantissa... so it is not a
>interger...and surely not a perfect square.
>
>Well my question is... how can i verify if a number has mantissa???

A floating point number *ALWAYS* has a mantissa, regardless of whether
it is an exact integer or not.

fmod(x, 1.0) should return an exact zero if x is an exact integer
(in a floating-point variable). Two problems: fmod() is not defined
to be exact, although in practice that should not be a problem.
Also x might not be an exact integer even if it mathematically
SHOULD be exact, and sqrt() is likely to have roundoff error.

Gordon L. Burditt

Saif
Guest
Posts: n/a

 11-25-2005

fzmaster wrote:
> Actually i need to know how to detect if a number is a perfect square.
> But i'v been thinking..
> if i sqrt(x) and check if this result has mantissa... so it is not a
> interger...and surely not a perfect square.
>
> Well my question is... how can i verify if a number has mantissa???

If(number - floor(number) == 0) then your number is an integer
else not.