Results 1 to 10 of 10

Thread: machine epsilon

  1. #1
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Exclamation 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 12:02 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,556
    Rep Power
    23

    Default

    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. #3
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Default

    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 09:26 PM.

  4. #4
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Default

    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.
    Please suggest.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,556
    Rep Power
    23

    Default

    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. #6
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Default

    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. #7
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Default

    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. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,556
    Rep Power
    23

    Default

    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. #9
    rosh72851 is offline Member
    Join Date
    Sep 2008
    Posts
    58
    Rep Power
    0

    Default

    111111100000000000000000000000
    This definitely is not the binary for integer 1.

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,556
    Rep Power
    23

    Default

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

Similar Threads

  1. machine epsilon
    By rosh72851 in forum New To Java
    Replies: 2
    Last Post: 09-23-2008, 10:21 PM
  2. 32 bit machine or 64 bit machine
    By Kapil Gupta in forum Advanced Java
    Replies: 13
    Last Post: 06-24-2008, 03:29 AM
  3. Getting name/ip of a machine
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-02-2008, 07:11 PM
  4. Too many virtual Machine
    By davantmay in forum Java Applets
    Replies: 1
    Last Post: 07-06-2007, 10:53 PM
  5. Virtual Machine To Pda
    By Heather in forum Advanced Java
    Replies: 2
    Last Post: 06-30-2007, 03:11 PM

Posting Permissions

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