I have an assignment in which I have to create a 16-byte float, allocating bits to mantissa, exponent, sign of mantissa and sign of exponent at my own discretion. I have planned it to be as follows -
Bits Purpose
1 Sign of mantissa
2 – 32 Mantissa
33 Sign of exponent
34-128 Exponent of 10

Please guide me on how can I store this information, and perform addition & multiplication in this types.
I understand I have to use bitwise operators, but I m stuck.

5
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by nucleon

long double on some compilers can be aligned to 128 bits.

Otherwise create a class, overload math operators. That's all I can say, since I don't know what you're really stuck on.

I would reserve more bit space for the mantissa. Up to 64 or even more.

I don't have to use the inbuilt "float" for the operations. So, since the mantissa may not be in the range of an integer, i'll have to input and manipulate them as strings. I don't want to do that. There should be some way to bitwise manipulate the numbers.

long double on some compilers can be aligned to 128 bits.

Otherwise create a class, overload math operators. That's all I can say, since I don't know what you're really stuck on.

I have an assignment in which I have to create a 16-byte float, allocating bits to mantissa, exponent, sign of mantissa and sign of exponent at my own discretion. I have planned it to be as follows -
Bits Purpose
1 Sign of mantissa
2 – 32 Mantissa
33 Sign of exponent
34-128 Exponent of 10

Please guide me on how can I store this information, and perform addition & multiplication in this types.
I understand I have to use bitwise operators, but I m stuck.

Well, start from
and
http://msdn.microsoft.com/en-us/library/4ke0e88k(VS.71).aspx
then come back with your codes...

ddanbe> I would reserve more bit space for the mantissa.
Maybe it's a "special purpose" trade off: massive range at the expense of precision. Purpose unspecified. ;)

But the OP may be confusing mantissa and exponent. In the usual types, the mantissa always has more bits than the exponent. Here's how your layout compares:

Bits allocated for:
exp  mant
stnd single:    8    23
stnd double:   11    52
yours:         95    31
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.