77,881
edits
(→In the core series games: It's the division/overflow that results in most of the issues, not the incorrect lookup) |
m (→Calculation: It's ((y - y0)/m) that was supposed to range from 1 to 100, not (y - y0).) |
||
Line 129: | Line 129: | ||
|} | |} | ||
If one of the entries in the table matches, the final length of the Magikarp in millimeters is then calculated as follows. Due to a programming error, the function does not output <math display="inline">100 \cdot x_0 + \left\lfloor \frac{y - y_0}{m} \right\rfloor</math> as intended. The division routine expects the dividend to be an unsigned 16-bit value, but the subtraction always results in a negative value because ''y'' is always less than ''y<sub>0</sub>''. Additionally, only the low byte of the quotient is read, as the | If one of the entries in the table matches, the final length of the Magikarp in millimeters is then calculated as follows. Due to a programming error, the function does not output <math display="inline">100 \cdot x_0 + \left\lfloor \frac{y - y_0}{m} \right\rfloor</math> as intended. The division routine expects the dividend to be an unsigned 16-bit value, but the subtraction always results in a negative value because ''y'' is always less than ''y<sub>0</sub>''. Additionally, only the low byte of the quotient is read, as the quotient was intended to only range from 1 to 100. These result in the sizes not correctly following a normal distribution as intended. | ||
<math display="block">\textit{Size} = 100 \cdot x_0 + \left( \left\lfloor \frac{65536 + y - y_0}{m} \right\rfloor \mathrm{mod}\ 256 \right)</math> | <math display="block">\textit{Size} = 100 \cdot x_0 + \left( \left\lfloor \frac{65536 + y - y_0}{m} \right\rfloor \mathrm{mod}\ 256 \right)</math> |