… | |
… | |
951 | /* fast integer to ascii */ |
951 | /* fast integer to ascii */ |
952 | |
952 | |
953 | /* |
953 | /* |
954 | * This code is pretty complicated because it is general. The idea behind it, |
954 | * This code is pretty complicated because it is general. The idea behind it, |
955 | * however, is pretty simple: first, the number is multiplied with a scaling |
955 | * however, is pretty simple: first, the number is multiplied with a scaling |
956 | * factor (2**bits / 10**(digits-1)) to convert nthe integer into a fixed-point |
956 | * factor (2**bits / 10**(digits-1)) to convert the integer into a fixed-point |
957 | * number with the first digit in the upper bits. |
957 | * number with the first digit in the upper bits. |
958 | * Then this digit is converted to text and masked out. The resulting number |
958 | * Then this digit is converted to text and masked out. The resulting number |
959 | * is then multiplied by 10, by multiplying the fixed point representation |
959 | * is then multiplied by 10, by multiplying the fixed point representation |
960 | * by 5 and shifting the (binary) decimal point one to the right, so a 4.28 |
960 | * by 5 and shifting the (binary) decimal point one to the right, so a 4.28 |
961 | * format becomes 5.27, 6.26 and so on. |
961 | * format becomes 5.27, 6.26 and so on. |