Skip to content

Commit

Permalink
Merge fix #121
Browse files Browse the repository at this point in the history
  • Loading branch information
skolson committed Aug 13, 2020
2 parents ec86fd3 + c2dbd75 commit dfe5360
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,13 @@ class BigDecimal private constructor(
}
if (floatingPointString.contains('E') || floatingPointString.contains('e')) {
// Sci notation
val split = floatingPointString.split('.')
val split = if (floatingPointString.contains('.').not()) {
// As is case with JS Double.MIN_VALUE
val splitAroundE = floatingPointString.split('E', 'e')
listOf(splitAroundE[0], "0E" + splitAroundE[1])
} else {
floatingPointString.split('.')
}
when (split.size) {
2 -> {
val signPresent = (floatingPointString[0] == '-' || floatingPointString[0] == '+')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class BigDecimalCreationTest {
val b = BigDecimal.fromIntWithExponent(-123123, 2)
a == b
}

assertTrue {
val a = BigDecimal.parseStringWithMode("5E-324")
val b = BigDecimal.fromIntWithExponent(5, -324)
a == b
}
}

@Test
Expand Down

0 comments on commit dfe5360

Please sign in to comment.