Nicholas Charles
Nicholas Charles

Reputation: 41

How many bits of an int match the precsion of a 32 bit floating point?

I am trying to compare the timing and cost of synthesizing floating point operators vs integer operators, but in order to properly compare them I need to use the same relative amount of bits for the integer operation that is represented in a 32 bit floating point number. Appreciate any help!

Upvotes: 0

Views: 61

Answers (1)

Malcolm McLean
Malcolm McLean

Reputation: 6404

An IEEE 32 bit floating point has one sign bit, eight exponent bits, and 23 mantissa bits. So an int with 24 bits has the same expressive power for precision, but of course the whole point of a float is that you have extra range. You can emulate the floating point in software if you want, this is likely to be valuable as a learning exercise. Or you can use fixed point ints with as many bits as you want after the binary point, but you'll need 24 to represent 1.xxxx as accurately as a float. It's not clear what you intend to do.

Upvotes: 1

Related Questions