I have to write a program in MIPS assembly (32bits) checking whether fixed point decimal number can be written accurately in ieee754.
I know the structure of float, hence i do it like:
- split number with comma into integer and fractional part
- convert them separately into integers (take first to left multiply by 10 and add next)
- shift register with this int right untill it is zero (to know number of bits)
However, the problems starts if the program gets number with let's say 3 leading ones and then we have 40 zeroes. It still can be written accurately but is impossible to detect in my program (as i store ints as 32bit numbers). And so my question is:
- How to write properly part with changing single digits into integers?
To recall, I have to perform 2 operations: multiply everything i have by 10 and then add another digit
Can it be done by shifting everything step by step and then indicating overflow on every 4 registers?
(if ov==1 then shift higher reg left and put one?)
Maybe there is a better way using let's say hi and low register from multiplication procedure?
Appreciate any help:)