Skip to content
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

Added decimal overload for MathJS.Math.Round #1305

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/stdlib/WebSharper.MathJS/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ module Definition =
[|
BaseNumber.Type
T<float>
T<decimal>
T<int>
Unit.Type
|]
Expand All @@ -158,6 +159,7 @@ module Definition =
[|
BaseNumber.Type
T<float>
T<decimal>
T<int>
Unit.Type
|]
Expand Down
9 changes: 9 additions & 0 deletions tests/WebSharper.Tests/MathJS.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ let Tests runServerSide =
equalMsg (MathJS.Math.Add(1., 2., 3.)) 6. "MathJS.Math.Add(1., 2., 3.) = 6"
}

Test "MathJS add (decimal)" {
equalMsg (MathJS.Math.Add(1.0m, 0.1m, 2.0m, 0.2m)) 3.3m "MathJS.Math.Add(1.0m, 0.1m, 2.0m, 0.2m) = 3.3m"
}

Test "MathJS add (fraction)" {
let a = MathJS.Math.Fraction(0.1)
Expand Down Expand Up @@ -288,6 +291,12 @@ let Tests runServerSide =
equal (floor x) 18133887298m
}

Test "MathJS.Math.Round" {
let x = 18133887298.441562272235520m
equal (MathJS.Math.Round(x, 0m)) 18133887298m
equal (MathJS.Math.Round(x, 2m)) 18133887298.44m
}

Test "Decimal comparison" {
let x = 18133887298.441562272235520m
let y = 18133887298.441562272237357m
Expand Down