"nice" floating-point literals seem to work
This commit is contained in:
parent
0d0455ce92
commit
f17720731d
3 changed files with 14 additions and 13 deletions
|
@ -88,7 +88,6 @@ function main
|
||||||
local tokens
|
local tokens
|
||||||
|
|
||||||
fill_in_powers_of_10()
|
fill_in_powers_of_10()
|
||||||
print_powers_of_10()
|
|
||||||
|
|
||||||
dat_banned_objmacros = 255
|
dat_banned_objmacros = 255
|
||||||
dat_banned_fmacros = 255
|
dat_banned_fmacros = 255
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
char * = "How are you"" d""o""i""ng today?\n";
|
char * = "How are you"" d""o""i""ng today?\n";
|
||||||
hi
|
hi
|
||||||
_TEST _ING _1
|
_TEST _ING _1
|
||||||
4.2
|
1.00001
|
||||||
|
|
|
@ -122,6 +122,7 @@ function tokenize
|
||||||
local data
|
local data
|
||||||
local significand
|
local significand
|
||||||
local exponent
|
local exponent
|
||||||
|
local new_exponent
|
||||||
local pow10
|
local pow10
|
||||||
local integer
|
local integer
|
||||||
local fraction
|
local fraction
|
||||||
|
@ -305,24 +306,25 @@ function tokenize
|
||||||
putc(10)
|
putc(10)
|
||||||
if integer == 0 goto float_no_integer
|
if integer == 0 goto float_no_integer
|
||||||
; now deal with the integer part
|
; now deal with the integer part
|
||||||
n = leftmost_1bit(integer)
|
new_exponent = leftmost_1bit(integer)
|
||||||
n += 1
|
new_exponent -= 58
|
||||||
|
n = new_exponent - exponent
|
||||||
significand = right_shift(significand, n)
|
significand = right_shift(significand, n)
|
||||||
exponent += n
|
exponent = new_exponent
|
||||||
significand += right_shift(integer, exponent)
|
significand += right_shift(integer, exponent)
|
||||||
putn(significand)
|
|
||||||
putc(32)
|
|
||||||
putn_signed(exponent)
|
|
||||||
putc(10)
|
|
||||||
if *1in != 'e goto float_no_exponent
|
if *1in != 'e goto float_no_exponent
|
||||||
|
|
||||||
:float_no_exponent
|
:float_no_exponent
|
||||||
if significand == 0 goto float_zero
|
if significand == 0 goto float_zero
|
||||||
normalize_float(&significand, &exponent)
|
normalize_float(&significand, &exponent)
|
||||||
; reduce to 52-bit significant
|
putn(significand)
|
||||||
significand >= 6
|
putc(32)
|
||||||
exponent += 6
|
putn_signed(exponent)
|
||||||
exponent += 51 ; 1001010111... => 1.001010111...
|
putc(10)
|
||||||
|
; reduce to 53-bit significant (top bit is removed to get 52)
|
||||||
|
significand >= 5
|
||||||
|
exponent += 5
|
||||||
|
exponent += 52 ; 1001010111... => 1.001010111...
|
||||||
n = leftmost_1bit(significand)
|
n = leftmost_1bit(significand)
|
||||||
b = 1 < n
|
b = 1 < n
|
||||||
significand &= ~b
|
significand &= ~b
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue