diff options
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/math.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/testes/math.lua b/testes/math.lua index 0d228d09..54d19c40 100644 --- a/testes/math.lua +++ b/testes/math.lua | |||
| @@ -685,6 +685,18 @@ assert(eq(math.exp(0), 1)) | |||
| 685 | assert(eq(math.sin(10), math.sin(10%(2*math.pi)))) | 685 | assert(eq(math.sin(10), math.sin(10%(2*math.pi)))) |
| 686 | 686 | ||
| 687 | 687 | ||
| 688 | do print("testing ldexp/frexp") | ||
| 689 | global ipairs | ||
| 690 | for _, x in ipairs{0, 10, 32, -math.pi, 1e10, 1e-10, math.huge, -math.huge} do | ||
| 691 | local m, p = math.frexp(x) | ||
| 692 | assert(math.ldexp(m, p) == x) | ||
| 693 | local am = math.abs(m) | ||
| 694 | assert(m == x or (0.5 <= am and am < 1)) | ||
| 695 | end | ||
| 696 | |||
| 697 | end | ||
| 698 | |||
| 699 | |||
| 688 | assert(tonumber(' 1.3e-2 ') == 1.3e-2) | 700 | assert(tonumber(' 1.3e-2 ') == 1.3e-2) |
| 689 | assert(tonumber(' -1.00000000000001 ') == -1.00000000000001) | 701 | assert(tonumber(' -1.00000000000001 ') == -1.00000000000001) |
| 690 | 702 | ||
