Skip to content

Commit

Permalink
always include decimal digits in text
Browse files Browse the repository at this point in the history
  • Loading branch information
skyz1 committed Aug 1, 2023
1 parent bf7c6ed commit be3b805
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/Core/fixedDecimal.candy
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,12 @@ coerceIn value minimum maximum :=

toText a :=
needs (is a)
beforeDot = a | floorToInt | toDebugText
ifElse (a | scale | equals 0) { beforeDot } {
afterDot = run {
scaleFactor = a | scale | scaleFactor
tmp = a | minorUnits | int.remainder scaleFactor
ifElse (int.isNonNegative tmp) { tmp | int.add scaleFactor | toDebugText | text.removePrefix "1" } {
tmp | int.subtract scaleFactor | toDebugText | text.removePrefix "-1"
}
beforeDot = a | floorToInt
afterDot = run {
scaleFactor = a | scale | scaleFactor
tmp = a | minorUnits | int.remainder scaleFactor
ifElse (int.isNonNegative tmp) { tmp | int.add scaleFactor | toDebugText | text.removePrefix "1" } {
tmp | int.subtract scaleFactor | toDebugText | text.removePrefix "-1"
}
"{beforeDot}.{afterDot}"
}
"{beforeDot}.{afterDot}"

1 comment on commit be3b805

@jwbot
Copy link
Collaborator

@jwbot jwbot commented on be3b805 Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler

Benchmark suite Current: be3b805 Previous: 83cb450 Ratio
Time: Compiler/hello_world 25394055 ns/iter (± 621808) 24982559 ns/iter (± 3412713) 1.02
Time: Compiler/fibonacci 185673667 ns/iter (± 1318346) 222455421 ns/iter (± 11086515) 0.83
Time: VM Runtime/hello_world 72151 ns/iter (± 5302) 70950 ns/iter (± 35084) 1.02
Time: VM Runtime/fibonacci/15 494356944 ns/iter (± 1931574) 640840662 ns/iter (± 16354893) 0.77
Time: VM Runtime/PLB/binarytrees/6 2249409304 ns/iter (± 60855054) 2915153673 ns/iter (± 54214207) 0.77

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.