To avoid trivialization of this problem, the following calculation excludes inf and NaN. Since, without such exclusion, inf will always be the largest value.
The exponent range can be calculated using the following formula (where k denotes the number of exponent bits we choose to use):
Therefore, the range of The Gates cafe's exponent is: [-2, 5] (justified by the following calculation)
The range of La Prima's exponent is: [-14, 17] (justified by the following calculation)
The largest represent-able numerical float number is to have exponent pattern of all ones followed by 1 zero (Gates: 110, La Prima: 11110) and fractional pattern of all ones (Gates: 11111, La Prima: 111).
For the fractional part (denoted by M in my later calculation), since the largest value are in the normalized range, we add one to the binary value of the fractional pattern (Gates: 1.11111, La Prima: 1.111) before converting the binary into decimal (Gates: 15, La Prima: 63). And since these values are in decimals-form of binary, we need to divide by 2^f where f is the number of fractional bits we chose to use. (Gates: \frac{63}{2^5} = \frac{63}{32}, La Prima: \frac{15}{2^3} = \frac{15}{8}).
Finally, the maximum value is V = M*2^{\text{e_max}}.
The minimum represent-able numerical float number is to have all bits be 0 (Gates: 00000000, La Prima: 00000000). And the minimum value for both Gates and La Prima is 0.0.
Therefore, Gates has range [0.0, 15.75] and La Prima has range [0.0, 61440.00]
The step size in denormalized range can be caluclated using the following formula (where f indicates the number of fractional bits we chose to use)
We define the average step size as the following (where max is the maximum represent-able value, min is the minimum represent-able value, and n is the number of distinct represent-able value):
We exclude inf and NaN here.
Since step size varies, the best I can do is to tell you the step size around a float (where e is the current exponent of the value).
La Prima can represent bigger range, but Gates has higher precision.
The lowest exponent in Gates is -2, and we know that 4.00 = 16 * 2^{-2}. If it is in normalized range, the lowest fractional value is 32 with all 0 bits. Therefore -4 should be in denormalized range and the fractional bits 10000 represent 16. In summery, the exact value of -4 can be represented by 00010000.
We know that the bit representation of -4 is even.
Knowing this, we search the nearby value of 00010000 which is 00001111(exponent = -2, fractional = 15, value = 15 * 2^{-2} = 3.75) and 00010001 (exponent = -2, fractional = 17, value = 17 * 2^{-2} = 4.25). Since -4 is even, the range in which the price will round to 4 is [4-(4-3.75), 4+(4.25-4)] = [3.75, 4.25].
1| movq $0x213, (%rcx)
2| leaq 8(%rcx), %rax
3| movq (%rcx), (%rax)
Erroneous / No Info
At line 1, we do not know if the address %rcx is a valid address within allowed allocation space. Writing to protected/invalid area (e.g. 0x00) might cause seg-fault.
At line 3, de-referencing %rcx might be an invalid read (e.g. reading 0x00where it does not have an actual physical address) and writing to address %rax might be an invalid write to protected/invalid area of the memory.
4| movq $0x106, %rcx # %rcx = 0x106
5| leaq 1(, %rcx, 2), %rdx # %rdx = 1 + 0x20C = 0x20D
6| movq $0x75, %rbx # %rbx = 0x75
7| leaq (%rdx, %rbx, 4), %r12 # %r12 = 0x20D + 4*0x75 = 0x20D + 0x1D4 = 0x3E1
8| leaq (%r12), %rax # %rax = 0x3E1
The value of %rax is 0x3E1 as calculated from above.
Table of Content