Skip to content

Commit 7a00808

Browse files
committed
ugly hack to render floats right, but it works
1 parent 04fe91c commit 7a00808

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/HLL/sprintf.nqp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,14 @@ my module sprintf {
206206
$float := nqp::abs_n($float) * nqp::pow_n(10, $precision - ($exp + 1)) + 0.5;
207207
$float := nqp::floor_n($float);
208208
$float := $float / nqp::pow_n(10, $precision - ($exp + 1));
209-
$exp == -4 ?? stringify-to-precision($float, $precision + 3) !! $float;
209+
#?if jvm
210+
if $exp == -4 {
211+
$float := stringify-to-precision($float, $precision + 3);
212+
$float := nqp::substr($float, 0, nqp::chars($float) - 1) if nqp::chars($float) > 1 && $float ~~ /\.\d**4 0+$/;
213+
$float := nqp::substr($float, 0, nqp::chars($float) - 1) if nqp::chars($float) > 1 && $float ~~ /\.\d**4 0+$/;
214+
}
215+
$float
216+
#?endif
210217
}
211218
sub fixed-point($float, $precision, $size, $pad) {
212219
my $sign := $float < 0 ?? '-' !! '';

0 commit comments

Comments
 (0)