User Profile

Collapse

Profile Sidebar

Collapse
geliangwei
geliangwei
Last Activity: May 27 '07, 11:47 AM
Joined: Mar 4 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • geliangwei
    replied to how to check each bit of a float
    in C
    Thank you very much for your replies!

    I found another solution from Internet just now by using 'union'

    union four_byte
    {
    int i;
    float f;
    } share;

    share.f = 2.34;

    Then, I can access share.i as an integer. This seems easier.
    Is that ok?
    See more | Go to post

    Leave a comment:


  • geliangwei
    started a topic how to check each bit of a float
    in C

    how to check each bit of a float

    The 32-bit float number is defined by IEEE 754.
    Given a float variable, f, how to check whether each of the 32 bits is '1' or '0'?

    One possible solution is access f as a 32-bit int.
    That is define an integer i that accesses the same memory address where f is stored.
    Then, I can right shift i by one bit for 32 times and check whether the least significant bit is '1' or '0'.
    But how to let i and f share the...
    See more | Go to post
No activity results to display
Show More
Working...