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

F

fzmaster

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
 
G

Gordon Burditt

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
 
S

Saif

fzmaster said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top