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?

Printable View

- 09-23-2008, 06:59 PMrosh72851machine 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? - 09-23-2008, 08:09 PMNorm
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? - 09-23-2008, 08:23 PMrosh72851
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. - 09-23-2008, 10:29 PMrosh72851
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

Code:`Integer.toBinaryString(Float.floatToRawIntBits(value));`

Please suggest. - 09-23-2008, 11:19 PMNormQuote:

how do I convert float and double data types to binary

Quote:

answer doesnt seem to be right.

Quote:

1.0 + epsilon ==1.0

- 09-23-2008, 11:31 PMrosh72851Quote:

Everything in a computer is in binary. What format are you looking for? A String of "0"s and "1"s? or what?

Quote:

What does the output look like? Please post it.

Code:`111111100000000000000000000000`

- 09-23-2008, 11:34 PMrosh72851
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.

- 09-24-2008, 01:14 AMNorm
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.

Quote:

111111100000000000000000000000

The internal format for floats must be documented in many places online. - 09-24-2008, 01:33 AMrosh72851Quote:

111111100000000000000000000000

- 09-24-2008, 04:16 AMNorm
It's floating point not int.

Do some research on how floating point is represented on a computer.