IEEE Help

This is a discussion on IEEE Help within the C Programming forums, part of the General Programming Boards category; Hello, I would like to convert an int to a 32-bit value (as an IEEE floating point value). I've never ...

  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,185
    Is there a reason why you don't do
    Code:
    int foo = 16384;
    float bar = foo;
    ?

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,236
    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,185
    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, 09: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21