I am trying to build a class where user can compute some floating operations with a particular accuracy provided. Example : User wantFor example, if the user wants to have up to 4 numbersdigit accuracy thus, everything less than 0.0001 is zero and everything bigger than 9999 is inf.
I think the best way is to create a bit (or maybe byte) array to store sign, mantissa and exponent. For this "4istance, with 4 (decimal) numbers accuracy"digits accuracy I could calculate how many bits I would need to store smallest and biggest value and then create array of suchthat size.
This leadedleads me to two of my questions :
- Why does single precision hasuse exactly 8 bits for the exponent and 24 for the mantissa (IEEE 754) notrather than 10 and 53 nor, or 12 and 51? Is it some howsomehow relevant or is it just agreementa standard?
- Assuming I need 4 digit precision for 9999 it is, I would need 14 bits but how much space do I need to keep 0.0001 in 4 (decimal) digit accuracy?
If anthe answer for the 1st question is "it is just agreement"a standard" I have yet another question :
- How do I choose the best exponent and mantissa for my problem?
Please disregard thatthe fact numbers bigger and smaller might be calculated here (as I will just 'if' itthem out), but I. I do not want to use double/float/etc for this I need as much "space"(meaning biggerI expect to use more memory than a double) for numbers as I possibly can and save space ( would need but I dontdo not want to createuse too big array).
I hope this is not duplicate of any question - I couldnt find anything like this on googlemuch space.