1. Member
Join Date
Sep 2008
Posts
58
Rep Power
0

machine epsilon2

What would be the smallest positive float (epsilon) such that 1.0 + epsilon != 1.0f?
What is the condition that I have to use to attain this?
Last edited by rosh72851; 09-24-2008 at 01:02 AM.

2. have you tried writing a program to test this?
If not, do.

Are you using float to mean the java float type?

What is the smallest number that a float can hold?
What is the smallest number that a double can hold?

3. Member
Join Date
Sep 2008
Posts
58
Rep Power
0
For IEEE754 single precision 24 dgits, which include 7 decimals. (float)
For IEEE754 double precision 53 digits, which include 15 decimal places (double)

I have a program that achieves this formula 1.0 + epsilon ==1.0
i.e. epsilon is a biggest small number that is not big enough to change 1.0.
Last edited by rosh72851; 09-23-2008 at 10:26 PM.

4. Member
Join Date
Sep 2008
Posts
58
Rep Power
0
Ok I figured how to do that.

Next question, how do I convert float and double data types to binary. For float, ive used the function
Java Code:
`Integer.toBinaryString(Float.floatToRawIntBits(value));`
But the answer doesnt seem to be right.

5. how do I convert float and double data types to binary
Everything in a computer is in binary. What format are you looking for? A String of "0"s and "1"s? or what?
answer doesnt seem to be right.
What does the output look like? Please post it.
1.0 + epsilon ==1.0
Can you post the code that demos this?

6. Member
Join Date
Sep 2008
Posts
58
Rep Power
0
Everything in a computer is in binary. What format are you looking for? A String of "0"s and "1"s? or what?
Well obviously a string is the easiest way.

What does the output look like? Please post it.
If I input a value 1. The result I get is
Java Code:
`111111100000000000000000000000`
Ive already solved the epsilon problem.

7. Member
Join Date
Sep 2008
Posts
58
Rep Power
0
Going over the internet I can get ways only how to convert integers and not decimals (floats). If you could tell me how it works in real time, I can work on it myself.

8. If you just want to see the internal values of various variables you could use the DataOutputStream. It has methods to output different types.
Either write to a disk file or use a ByteArray to hold the output.
111111100000000000000000000000
Why do you think that value is wrong? It looks like it has enough bits.
The internal format for floats must be documented in many places online.

9. Member
Join Date
Sep 2008
Posts
58
Rep Power
0
111111100000000000000000000000
This definitely is not the binary for integer 1.

10. It's floating point not int.
Do some research on how floating point is represented on a computer.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•