Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

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

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

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

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 the
Boolean expression
x == 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 epsilon
http://www.cprogramming.com/tutorial/floating_point/understanding_floating_point_representation.html

Specifically, there is a constant in float.h called FLT_EPSILON which is the answer to your question for when x == 1

Because floats a finite approximations, adding sufficiently small values to a larger number has no effect.

--

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

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:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close