|
338 | 338 | @test *(a, b, c, d, f) == parse(BigFloat,"5.214588134765625e+04") |
339 | 339 | @test *(a, b, c, d, f, g) == parse(BigFloat,"1.6295587921142578125e+03") |
340 | 340 | end |
341 | | -@testset "< / > / <= / >=" begin |
342 | | - x = BigFloat(12) |
343 | | - y = BigFloat(42) |
344 | | - z = BigFloat(30) |
345 | | - @test y > x |
346 | | - @test y >= x |
347 | | - @test y > z |
348 | | - @test y >= z |
349 | | - @test x < y |
350 | | - @test x <= y |
351 | | - @test z < y |
352 | | - @test z <= y |
353 | | - @test y - x >= z |
354 | | - @test y - x <= z |
355 | | - @test !(x >= z) |
356 | | - @test !(y <= z) |
357 | | -end |
358 | 341 | @testset "rounding modes" begin |
359 | 342 | setprecision(4) do |
360 | 343 | # default mode is round to nearest |
|
371 | 354 | end |
372 | 355 | end |
373 | 356 | end |
374 | | - |
375 | 357 | @testset "copysign / sign" begin |
376 | 358 | x = BigFloat(1) |
377 | 359 | y = BigFloat(-1) |
@@ -473,10 +455,11 @@ end |
473 | 455 | @test isnan(nextfloat(BigFloat(NaN), 1)) |
474 | 456 | @test isnan(prevfloat(BigFloat(NaN), 1)) |
475 | 457 | end |
| 458 | + |
476 | 459 | # sqrt DomainError |
477 | 460 | @test_throws DomainError sqrt(BigFloat(-1)) |
478 | 461 |
|
479 | | -@testset "precision" begin |
| 462 | +@testset "setprecision" begin |
480 | 463 | old_precision = precision(BigFloat) |
481 | 464 | x = BigFloat(0) |
482 | 465 | @test precision(x) == old_precision |
|
512 | 495 | @test !isinteger(-BigFloat(Inf)) |
513 | 496 | @test !isinteger(BigFloat(NaN)) |
514 | 497 | end |
515 | | - |
516 | 498 | @testset "comparisons" begin |
517 | 499 | x = BigFloat(1) |
518 | 500 | y = BigFloat(-1) |
|
521 | 503 | imi = BigFloat(-Inf) |
522 | 504 | @test x > y |
523 | 505 | @test x >= y |
| 506 | + @test !(y >= x) |
524 | 507 | @test x >= x |
525 | 508 | @test y < x |
526 | 509 | @test y <= x |
| 510 | + @test !(x <= y) |
527 | 511 | @test y <= y |
528 | 512 | @test x < ipl |
529 | 513 | @test x <= ipl |
@@ -675,14 +659,17 @@ end |
675 | 659 | end |
676 | 660 | setprecision(21) do |
677 | 661 | @test string(parse(BigFloat, "0.1")) == "0.10000002" |
| 662 | + @test string(parse(BigFloat, "0.5")) == "0.5" |
678 | 663 | @test string(parse(BigFloat, "-9.9")) == "-9.9000015" |
679 | 664 | end |
680 | 665 | setprecision(40) do |
681 | 666 | @test string(parse(BigFloat, "0.1")) == "0.10000000000002" |
| 667 | + @test string(parse(BigFloat, "0.5")) == "0.5" |
682 | 668 | @test string(parse(BigFloat, "-9.9")) == "-9.8999999999942" |
683 | 669 | end |
684 | 670 | setprecision(123) do |
685 | 671 | @test string(parse(BigFloat, "0.1")) == "0.0999999999999999999999999999999999999953" |
| 672 | + @test string(parse(BigFloat, "0.5")) == "0.5" |
686 | 673 | @test string(parse(BigFloat, "-9.9")) == "-9.8999999999999999999999999999999999997" |
687 | 674 | end |
688 | 675 | end |
|
927 | 914 | @test i3+1 > f |
928 | 915 | @test i3+1 >= f |
929 | 916 | end |
| 917 | + |
930 | 918 | # issue #8318 |
931 | 919 | @test convert(Int64,big(500_000_000_000_000.)) == 500_000_000_000_000 |
932 | 920 |
|
|
935 | 923 | @test MPFR.get_emin() == MPFR.get_emin_min() |
936 | 924 | @test MPFR.get_emax() == MPFR.get_emax_max() |
937 | 925 | end |
| 926 | + |
938 | 927 | # issue #10994: handle embedded NUL chars for string parsing |
939 | 928 | @test_throws ArgumentError parse(BigFloat, "1\0") |
940 | 929 |
|
@@ -1025,7 +1014,6 @@ end |
1025 | 1014 | @test to_string(big"-1.0") == "-1.0" |
1026 | 1015 | end |
1027 | 1016 | end |
1028 | | - |
1029 | 1017 | @testset "big(::Type)" begin |
1030 | 1018 | for x in (2f0, pi, 7.8, big(ℯ)) |
1031 | 1019 | @test big(typeof(x)) == typeof(big(x)) |
|
0 commit comments