-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement big int module #7
base: main
Are you sure you want to change the base?
Conversation
src/gleam/javascript/big_int.gleam
Outdated
pub fn from_int(a: Int) -> BigInt | ||
|
||
@external(javascript, "../../ffi.mjs", "from") | ||
pub fn from_string(a: String) -> BigInt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work? What happens when it's not a valid string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it errors. updated from_string to return result but from_int can still return just a value
|
||
big_int.add(a, b) | ||
|> should.equal(big_int.from_string("18446744073709551617")) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have tests for all the functions please 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added for remaining functions
/// Zero division returns an error, this is different to core gleam number type | ||
/// and is chosen because this library aims to be smallest wrapper for ffi and | ||
/// where possible should emulate platform behaviour | ||
@external(javascript, "../../ffi.mjs", "divide") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Gleam dividing by zero returns zero. Let's do that to be consistent.
No description provided.