473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

judge whether a number is an integer or not

12
as title,
is there any function in C/C++ help me judge whether a number is an integer?
or is there any idea to write a function to complete this job?
Oct 8 '07 #1
6 2317
Banfa
9,065 Expert Mod 8TB
How is this number stored in memory?

Assuming that you are analysing a string then an integer consists of optionally a + or - as the first character followed by a string of digits. If anything other than a digit appears then it is not an integer.
Oct 8 '07 #2
JosAH
11,448 Expert 8TB
as title,
is there any function in C/C++ help me judge whether a number is an integer?
or is there any idea to write a function to complete this job?
Have a look at the modf() function; it breaks up a number into its fractional and
integer parts. If the fractional part equals zero the number logically is an integer.

kind regards,

Jos
Oct 8 '07 #3
Ganon11
3,652 Expert 2GB
Have a look at the modf() function; it breaks up a number into its fractional and
integer parts. If the fractional part equals zero the number logically is an integer.

kind regards,

Jos
Is it modf(), or fmod()?

EDIT: Wow, apparantly it's both.
Oct 8 '07 #4
Banfa
9,065 Expert Mod 8TB
Is it modf(), or fmod()?

EDIT: Wow, apparantly it's both.
Read your links Ganon, those functions are not quite the same :D
Oct 8 '07 #5
Ganon11
3,652 Expert 2GB
I realize they're not the same, but both can work (in their own way) for this problem. I was just surprised that what I thought was a typo on Jos' part turned out to be a n actual function.
Oct 8 '07 #6
huan
12
Thanks a lots!! I got it~ :D
Oct 12 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: aling | last post by:
Given: signed a, b; How to judge overflow of the sum of these two operands? Just use one *if* statement. Is this statement right? if ((a>0 && b>0 && sum<=0) || (a<0 && b<0 && sum>=0)) //...
2
by: Reddy | last post by:
Hi, How to check whether a given number is an integer Thanks, Reddy
3
by: dahuzizyd | last post by:
Hi all I want to judge an application is runing or not when another application start . If the application is running , get focus. I use the Pinvoke to invoke the FindWindow function ,I...
2
by: morgan.chengmo | last post by:
How to judge whether a browser supports ActiveX? Some browser like Firefox doens't support ActiveX by default, but can do it with plugin support. Take Firefox for example, it has a whitelist...
1
by: sword | last post by:
This my first starting a new topic in English. I want to ask if I want to judge whether a file exists how I should do. I program with C++. Thank you.
6
by: Morgan Cheng | last post by:
I know that HttpWebRequest.GetResponse() generates a HttpWebResonse. The response has one ContentType property. But the property is just decided by http response header. It is possible that the...
5
by: André | last post by:
Hello, I need to know whether the result of a division is a integer or not. dim x =60 dim y = 3 if x/y is a integer then .... else ....
26
by: momobear | last post by:
hi, I am puzzled about how to determine whether an object is initilized in one class, anyone could give me any instructions? here is an example code: class coffee: def boil(self): self.temp =...
20
by: ravi | last post by:
Give a one-line C expression to test whether a number is a power of 2.
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.