Created
March 13, 2019 07:35
-
-
Save usev6/8b21e936a2ee7850345086dd744104e3 to your computer and use it in GitHub Desktop.
special case for floats with $exp == 4 on JVM backend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/HLL/sprintf.nqp b/src/HLL/sprintf.nqp | |
index c15d371a4..50f80be9e 100644 | |
--- a/src/HLL/sprintf.nqp | |
+++ b/src/HLL/sprintf.nqp | |
@@ -327,11 +327,14 @@ my module sprintf { | |
$float := nqp::div_n($float, nqp::pow_n(10.0, nqp::sub_n($precision, nqp::add_n($exp, 1.0)))); | |
#?if jvm | |
if $exp == -4 { | |
- $float := stringify-to-precision($float, $precision + 3); | |
- $float := nqp::substr($float, 0, nqp::chars($float) - 1) if nqp::chars($float) > 1 && $float ~~ /\.\d**4 0+$/; | |
- $float := nqp::substr($float, 0, nqp::chars($float) - 1) if nqp::chars($float) > 1 && $float ~~ /\.\d**4 0+$/; | |
+ my $float_str := stringify-to-precision($float, $precision + 3); | |
+ $float_str := nqp::substr($float_str, 0, nqp::chars($float_str) - 1) if nqp::chars($float_str) > 1 && $float_str ~~ /\.\d**4 0+$/; | |
+ $float_str := nqp::substr($float_str, 0, nqp::chars($float_str) - 1) if nqp::chars($float_str) > 1 && $float_str ~~ /\.\d**4 0+$/; | |
+ $float_str | |
+ } | |
+ else { | |
+ $float | |
} | |
- $float | |
#?endif | |
} | |
sub fixed-point(num $float, $precision, $size, $pad, $/) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment