473,466 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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

Nov 25 '05 #1
2 2977
>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
Nov 25 '05 #2

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.

Nov 25 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: jose luis fernandez diaz | last post by:
Hi, My OS is: cronos:jdiaz:tmp>uname -a HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license I compile in 64-bits mode the program below:
0
by: Support | last post by:
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"> <head>...
7
by: A. L. | last post by:
Consider following code segment: #1: double pi = 3.141592653589; #2: printf("%lf\n", pi); #3: printf("%1.12lf\n", pi); #4: printf("%1.15lf\n", pi); The above code outputs as following: ...
2
by: Wayne Wengert | last post by:
I want to write a Windows application to go through all the email addresses in an SQL Server table and to report which ones are invalid. From Googling and perusing NGs it is my understanding that...
5
by: s.schmeier | last post by:
Hi everybody, we want extract numbers from strings and wonder if there is already a module around for doing this. An example in our case would look like this: 0.032 +/- 0.5 x 10(-4) it...
6
by: Chris Theis | last post by:
Hi all, I'm currently facing something which is quite annoying and probably one of you might have an idea of how to solve it efficiently. I have some software (upon which I have no...
43
by: Xancatal | last post by:
Hey everybody. I need help on this one. I need to verify that a number entered by a user is not either a negative number (-100.00), or an alphabet (a, b, c, X, Y) as well as other number other than...
28
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
18
by: Carramba | last post by:
Hi! is there a better/faster way to compare mantissas of to real number then in following code? #include <stdio.h> #include <stdlib.h> int main(void) { float a,b; int test;
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.