Liste des Groupes | Revenir à cl c |
[...] I noticed this strange discrepancy between
between my hex floats and C's. In C, this value:
>
0x12.34p10
>
has the decimal value 18640.0; why was that? It turns that this is:
>
18.203125 x 2 ** 10
>
The main part is interpreted as actual hex; the exponent is in
decimal, and exponent scaling is in binary bits. So THREE diferent
bases are involved!
>
In my scheme (which as I said worked for bases from 2 to 16), the
0x12.34p10 value would mean this:
>
18.203125 x 16 ** 16 ~= 3.58e20
>
The same base is used for all parts, including the exponent, and the
digits that are to be shifted. After all in decimal, 12.34e10 would
mean:
>
12.34 x 10 ** 10 = 123400000000.0
>
In my language, a base 5 version 5x12.34e10 (not valid below base 5)
would mean this (I think, as I no longer have the compiler):
>
7.76 x 5 ** 5 = 24250.0
>
This has a consistency lacking in C's hex floats.
Les messages affichés proviennent d'usenet.