Smart questions
Smart people
 Find A ForumFind An Expert
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Remember Me

Are you a
Computer / IT professional?
Join Tek-Tips now!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Just copy and paste the

#### Feedback

"...I think the forum is a great idea, especially for those of us in consulting engineering. Keep up the good work!..."

#### Geography

Where in the world do Tek-Tips members come from?

# int, float, for loop question

 Forum Search FAQs Links Jobs Whitepapers MVPs
 MisterClemens (Programmer) 4 Feb 06 15:07
 I am trying to write a program that satisfies these conditions:Write a program that will find and output the smallest positive integer float value x for which theBoolean expressionx == x + (1.0 / n)is true for some positive int variable n.However, i don't want anyone to write the program for me, i just want to understand what this program is asking, can someone please clarify this?
 cpjust (Programmer) 4 Feb 06 15:38
 "integer float value" is an oxymoron.  Integers are whole numbers, while floating point numbers are fractional.I'm not a math expert, but I can't see how that equation can ever be true.  The only way it could be true is if n = 0, which it can't if the question states that n is a positive number.
 Salem (Programmer) 4 Feb 06 16:19
 Basically, you're trying to determine epsilonhttp://www.cprogramming.com/tutorial/floating_point/understanding_floating_point_representation.htmlSpecifically, there is a constant in float.h called FLT_EPSILON which is the answer to your question for when x == 1Because floats a finite approximations, adding sufficiently small values to a larger number has no effect. --

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!