Skip to content

Conversation

dkhalanskyjb
Copy link
Contributor

This is done to support LocalDate.daysUntil(...): Int always
having a precise value. Additionally, it allows to simplify some
parts of the implementation.

Before, the Native implementation was using the same representable
ranges as the Java implementation; now, it uses the same ranges as
the JS implementation, which are narrower so that everything fits
in a JS number.

@dkhalanskyjb dkhalanskyjb requested a review from ilya-g July 22, 2020 12:47
val sum = a + b
// check for a change of sign in the result when the inputs have the same sign
if ((a xor sum) < 0 && (a xor b) >= 0) {
throw ArithmeticException("Addition overflows a long: $a + $b")
Copy link
Member

Choose a reason for hiding this comment

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

"an int"

This is done to support `LocalDate.daysUntil(...): Int` always
having a precise value. Additionally, it allows to simplify some
parts of the implementation.

Before, the Native implementation was using the same representable
ranges as the Java implementation; now, it uses the same ranges as
the JS implementation, which are narrower so that everything fits
in a JS number.
@dkhalanskyjb dkhalanskyjb force-pushed the native-smallerRange branch from cb3c93a to d8f09e2 Compare July 24, 2020 08:43
@dkhalanskyjb dkhalanskyjb merged commit ea0c1d9 into master Jul 24, 2020
@dkhalanskyjb dkhalanskyjb deleted the native-smallerRange branch July 24, 2020 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants