-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpm1_128_test.go
More file actions
53 lines (47 loc) · 1.87 KB
/
expm1_128_test.go
File metadata and controls
53 lines (47 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package floats
import (
"math"
"testing"
)
func TestFloat128_Expm1(t *testing.T) {
tests := []struct {
x Float128
want string
}{
{exact128(-0x1p24), "-1"},
{exact128(-1), "-0.6321205588285576784044762298385391325541888689682321654921631983025385042551001966"},
{exact128(-0x1p-24), "-5.96046429990338208927884783441062475300635261015299376854993634082159971776677455E-8"},
{exact128(-0x1p-25), "-2.980232194360610706156728457749074378475050447510024450735796644104588740223894263E-8"},
{exact128(0), "0"},
{exact128(0x1p-25), "2.980232283178452676169258265480484667505915170034780254106203474178642385993634061E-8"},
{exact128(0x1p-24), "5.960464655174749969329045951426788010322030160311252070356772304688050582038483484E-8"},
{exact128(0.25), "0.2840254166877414840734205680624364583362808652814630892175072968722077658672380028"},
{exact128(1), "1.718281828459045235360287471352662497757247093699959574966967627724076630353547595"},
{exact128(10), "22025.46579480671651695790064528424436635351261855678107423542635522520281857079258"},
{exact128(36), "4311231547115194.227113422292856925390788863616780347730770167843912372047055558563"},
{exact128(62), "843835666874145448907332947.0373117960080692679667410404618178186988225756502453424"},
}
for _, tt := range tests {
got := tt.x.Expm1()
if !close128(got, tt.want) {
t.Errorf("Expm1(%v) = %v; want %v", tt.x, got, tt.want)
}
}
strictTests := []struct {
x Float128
want Float128
}{
{exact128(0), exact128(0)},
{exact128(math.Copysign(0, -1)), exact128(math.Copysign(0, -1))},
// special cases
{exact128(math.Inf(1)), exact128(math.Inf(1))},
{exact128(math.Inf(-1)), exact128(-1)},
{exact128(math.NaN()), exact128(math.NaN())},
}
for _, tt := range strictTests {
got := tt.x.Expm1()
if !eq128(got, tt.want) {
t.Errorf("Expm1(%v) = %v; want %v", tt.x, got, tt.want)
}
}
}