From 4b09baa0a030d899b7e75bb81828e0d9df90ce32 Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Tue, 11 Feb 2014 15:06:24 -0600 Subject: use `.f` instead of `.16e` for floats It doesn't write a trailing zero, but it's better than floats being all over your screen. --- lib/system/sysstr.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index 4244bae4c..a6a555c08 100644 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -252,8 +252,8 @@ proc nimIntToStr(x: int): string {.compilerRtl.} = proc nimFloatToStr(x: float): string {.compilerproc.} = var buf: array [0..59, char] - c_sprintf(buf, "%#.16e", x) - return $buf + c_sprintf(buf, "%#.f", x) + result = $buf proc nimInt64ToStr(x: int64): string {.compilerRtl.} = result = newString(sizeof(x)*4) -- cgit 1.4.1-2-gfad0 From 33fcd112360c60078ae7ee4ddb93cbe9f44393bd Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Tue, 11 Feb 2014 17:00:22 -0600 Subject: add a trailing zero to $float --- lib/system/sysstr.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index a6a555c08..eb9d2000b 100644 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -254,6 +254,8 @@ proc nimFloatToStr(x: float): string {.compilerproc.} = var buf: array [0..59, char] c_sprintf(buf, "%#.f", x) result = $buf + if result[len(result)-1] == '.': + result.add("0") proc nimInt64ToStr(x: int64): string {.compilerRtl.} = result = newString(sizeof(x)*4) -- cgit 1.4.1-2-gfad0