mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
LibM: Implement various functions.
Path from Anonymous.
This commit is contained in:
parent
e51c1aa3d4
commit
c13be2c7ea
3 changed files with 147 additions and 53 deletions
|
@ -14,6 +14,24 @@ TEST_CASE(trig)
|
|||
EXPECT_CLOSE(cos(-1), 0.594715);
|
||||
EXPECT_CLOSE(tan(-1), -1.459446);
|
||||
EXPECT(isnan(sqrt(-1)));
|
||||
EXPECT(isnan(asin(1.1)));
|
||||
EXPECT(isnan(asin(-1.1)));
|
||||
EXPECT_CLOSE(asin(0), 0.0);
|
||||
EXPECT_CLOSE(asin(0.01), 0.01);
|
||||
EXPECT_CLOSE(asin(0.1), 0.100167);
|
||||
EXPECT_CLOSE(asin(0.3), 0.304693);
|
||||
EXPECT_CLOSE(asin(0.499), 0.522444);
|
||||
EXPECT_CLOSE(asin(0.5), 0.523599);
|
||||
EXPECT_CLOSE(asin(0.501), 0.524754);
|
||||
EXPECT_CLOSE(asin(0.9), 1.119770);
|
||||
EXPECT_CLOSE(asin(0.99), 1.429246);
|
||||
EXPECT_CLOSE(asin(1.0), 1.570750);
|
||||
EXPECT_CLOSE(atan(0), 0.0)
|
||||
EXPECT_CLOSE(atan(0.5), 0.463648)
|
||||
EXPECT_CLOSE(atan(-0.5), -0.463648)
|
||||
EXPECT_CLOSE(atan(5.5), 1.390943)
|
||||
EXPECT_CLOSE(atan(-5.5), -1.390943)
|
||||
EXPECT_CLOSE(atan(555.5), 1.568996)
|
||||
}
|
||||
|
||||
TEST_CASE(other)
|
||||
|
@ -51,4 +69,17 @@ TEST_CASE(exponents)
|
|||
EXPECT_EQ(exp(1000), std::numeric_limits<double>::infinity());
|
||||
}
|
||||
|
||||
TEST_CASE(logarithms)
|
||||
{
|
||||
EXPECT(isnan(log(-1)));
|
||||
EXPECT(log(0) < -1000000);
|
||||
EXPECT_CLOSE(log(0.5), -0.693233)
|
||||
EXPECT_CLOSE(log(1.1), 0.095310)
|
||||
EXPECT_CLOSE(log(5), 1.609480)
|
||||
EXPECT_CLOSE(log(5.5), 1.704842)
|
||||
EXPECT_CLOSE(log(500), 6.214104)
|
||||
EXPECT_CLOSE(log2(5), 2.321989)
|
||||
EXPECT_CLOSE(log10(5), 0.698988)
|
||||
}
|
||||
|
||||
TEST_MAIN(Math)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue