about summary refs log tree commit diff stats
path: root/408print-float.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-25 23:35:51 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-25 23:35:51 -0800
commit6173a84f35207b11ef3658d8990c4058eedd995b (patch)
treee6f4bf7f04c9bf76928a2bf8271e56afafdd0c6d /408print-float.mu
parentc6446c1f3d6af1285422fc17d333c3db1789a40d (diff)
downloadmu-6173a84f35207b11ef3658d8990c4058eedd995b.tar.gz
7274
Fix a bug in whole integer support. And we'll forget about compressing
large integers into scientific notation for now.
Diffstat (limited to '408print-float.mu')
-rw-r--r--408print-float.mu18
1 files changed, 11 insertions, 7 deletions
diff --git a/408print-float.mu b/408print-float.mu
index ced7aeea..3dca50ec 100644
--- a/408print-float.mu
+++ b/408print-float.mu
@@ -367,7 +367,7 @@ fn test-print-float-decimal-approximate-integer-5 {
   var hundred-thousand-f/xmm0: float <- convert hundred-thousand
   print-float-decimal-approximate screen, hundred-thousand-f
   #
-  check-screen-row screen, 1, "1e5 ", "F - test-print-float-decimal-approximate-integer-5"
+  check-screen-row screen, 1, "100000 ", "F - test-print-float-decimal-approximate-integer-5"
 }
 
 fn test-print-float-decimal-approximate-zero {
@@ -505,8 +505,12 @@ fn print-float-decimal-approximate screen: (addr screen), n: float {
     break-if-!=
     var result/eax: int <- copy mantissa
     result <- or 0x00800000  # insert implicit 1
-    result <- repeated-shift-left result, exponent
-    result <- shift-right 0x17  # 24 bits
+#?     print-string 0, "mantissa2: "
+#?     print-int32-hex 0, result
+#?     print-string 0, "\n"
+    var all-but-exponent/edx: int <- copy 0x17  # 23 bits for mantissa treated as a whole number
+    all-but-exponent <- subtract exponent
+    result <- repeated-shift-right result, all-but-exponent
 #?     print-string 0, "result: "
 #?     print-int32-hex 0, result
 #?     print-string 0, "\n"
@@ -525,8 +529,8 @@ fn print-float-decimal-approximate screen: (addr screen), n: float {
     # normal numbers
     print-string screen, "1"
   }
-#?   var mantissa/ebx: int <- copy bits
-#?   mantissa <- and 0x7fffff
+  var mantissa/ebx: int <- copy bits
+  mantissa <- and 0x7fffff
   compare mantissa, 0
   {
     break-if-=
@@ -543,7 +547,7 @@ fn print-float-decimal-approximate screen: (addr screen), n: float {
 }
 
 #? fn main -> _/ebx: int {
-#?   run-tests
-#? #?   test-print-float-decimal-approximate-integer
+#? #?   run-tests
+#?   test-print-float-decimal-approximate-integer-5
 #?   return 0
 #? }