Float anatomy
A float read from standard input sits in s0. Take it apart the way IEEE 754 lays it out, and say what kind of value it is. With the stdin box as given the program prints:
sign=1 exponent=129 fraction=0x580000
normal, 2^2
A single-precision float is 32 bits: the sign in bit 31 (1 means negative), a biased exponent in bits 30 to 23, and the fraction in bits 22 to 0. The exponent is stored with 127 added, which is the bias, so the stored 129 above means 2 to the power 2: 6.75 is 1.6875 times 4.
Copy the bits out of s0 into a w register with fmov. Nothing is converted: the same 32 bits move from the floating-point registers to the general ones, where the integer instructions can reach them. Then pull out the three fields (ubfx does it in one instruction each) and print them with fmt_parts.
The second line depends on the exponent:
- 255 (all ones):
infinitywhen the fraction is 0, otherwisenot a number - 0 (all zeros):
zerowhen the fraction is 0 (the sign still counts, so there is a negative zero), otherwisesubnormal, a number too small for the normal form - anything else:
normal, 2^e, where e is the exponent minus 127
What is checked
- both lines for the number in the stdin box, and for more numbers you cannot see
- the program exits cleanly
- the bits move with
fmov
specification
fmovWe run your program on the input above and on the hidden ones, and compare what it does. Nothing is matched against a stored solution.