Thread: IEEE Help

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    1

    IEEE Help

    Hello,

    I would like to convert an int to a 32-bit value (as an IEEE floating point value). I've never done C before so this is pretty confusing. I read somewhere that using the & mask would be a good way but I have no clue how to even start!

    Thanks for any tips or pointers

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Is there a reason why you don't do
    Code:
    int foo = 16384;
    float bar = foo;
    ?

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by tabstop View Post
    Is there a reason why you don't do
    Code:
    int foo = 16384;
    float bar = foo;
    ?
    If "float" is a 32-bit IEEE value, then of course, but the language doesn't guarantee it.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Of course, if the system doesn't use IEEE floats then why are we bothering to make one?

    If the answer is "because the assignment is to do so", then we can start talking about bit masks. On the other hand, bitwise math doesn't change from language to language so far as I know, so your knowledge of Java or whatever other language you've learned should be fine here. (And if you've managed to talk your way into a course where the first assignment is to build an IEEE float and you have no programming experience, then I admire your sweet-talking skills, but that doesn't really help you here.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IEEE Representation of Floats
    By Pnevma in forum C Programming
    Replies: 4
    Last Post: 01-28-2008, 10:06 AM
  2. IEEE problem
    By Lind in forum C Programming
    Replies: 3
    Last Post: 09-19-2007, 02:04 PM
  3. GPIB / IEEE 488 programming
    By nbo10 in forum C++ Programming
    Replies: 1
    Last Post: 08-27-2003, 01:52 PM
  4. IEEE Society for Students
    By Ben_Robotics in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-26-2003, 08:53 AM
  5. Reading 64 bit IEEE floating point from a file
    By rcobb in forum C Programming
    Replies: 1
    Last Post: 04-23-2003, 07:28 PM