Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

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

 
Reply With Quote
 
 
 
 
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
 
Reply With Quote
 
 
 
 
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to verify if an employee truely has an MCSE =?Utf-8?B?Qm9kaW5lOTU=?= Microsoft Certification 8 01-15-2010 06:52 AM
code to verify a number is valid network mask pacman2050@gmail.com C Programming 1 09-16-2007 09:59 AM
verify float number Xancatal C Programming 43 11-20-2006 11:33 AM
NEWBIE CGI HELP::Can I verify a user has logged on joe slash blow Perl Misc 4 09-01-2004 09:29 PM



Advertisments