blob: 1606fb103a4061f4e044bfd14f096e2977d94a1b [file] [log] [blame]
R version 3.6.2 Patched (2020-02-12 r77795) -- "Dark and Stormy Night"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> ## Tests for various features of IEC60559 doubles.
> ## Most of these are optional, so this is a sloppy test.
>
> # Goes to denormal (aka subnormal) numbers at -708.4
> exp(c(-745:-740, -730, -720, -710:-705))
[1] 4.940656e-324 9.881313e-324 1.976263e-323 5.434722e-323 1.531604e-322
[6] 4.199558e-322 9.226315e-318 2.032231e-313 4.476286e-309 1.216781e-308
[11] 3.307553e-308 8.990861e-308 2.443969e-307 6.643398e-307
>
> # goes to subnormal numbers at -308, to zero at ca 5e-324.
> 10^-(324:307)
[1] 0.000000e+00 9.881313e-324 9.881313e-323 9.980126e-322 9.999889e-321
[6] 9.999889e-320 9.999987e-319 1.000000e-317 1.000000e-316 1.000000e-315
[11] 1.000000e-314 1.000000e-313 1.000000e-312 1.000000e-311 1.000000e-310
[16] 1.000000e-309 1.000000e-308 1.000000e-307
> 2^-(1022:1075)
[1] 2.225074e-308 1.112537e-308 5.562685e-309 2.781342e-309 1.390671e-309
[6] 6.953356e-310 3.476678e-310 1.738339e-310 8.691695e-311 4.345847e-311
[11] 2.172924e-311 1.086462e-311 5.432309e-312 2.716155e-312 1.358077e-312
[16] 6.790387e-313 3.395193e-313 1.697597e-313 8.487983e-314 4.243992e-314
[21] 2.121996e-314 1.060998e-314 5.304989e-315 2.652495e-315 1.326247e-315
[26] 6.631237e-316 3.315618e-316 1.657809e-316 8.289046e-317 4.144523e-317
[31] 2.072262e-317 1.036131e-317 5.180654e-318 2.590327e-318 1.295163e-318
[36] 6.475817e-319 3.237909e-319 1.618954e-319 8.094772e-320 4.047386e-320
[41] 2.023693e-320 1.011846e-320 5.059232e-321 2.529616e-321 1.264808e-321
[46] 6.324040e-322 3.162020e-322 1.581010e-322 7.905050e-323 3.952525e-323
[51] 1.976263e-323 9.881313e-324 4.940656e-324 0.000000e+00
>
> # And because most libm pow() functions special-case integer powers.
> 10^-(324:307-0.01)/10^0.01
[1] 0.000000e+00 9.881313e-324 1.037538e-322 9.980126e-322 9.999889e-321
[6] 1.000038e-319 9.999987e-319 9.999997e-318 1.000000e-316 1.000000e-315
[11] 1.000000e-314 1.000000e-313 1.000000e-312 1.000000e-311 1.000000e-310
[16] 1.000000e-309 1.000000e-308 1.000000e-307
>
> # IEC60559 mandates this, but C99/C11 do not.
> # Mingw-w64 did not do so in v 2.0.1
> x <- 0*(-1) # negative zero
> sqrt(x)
[1] 0
> identical(x, sqrt(x))
[1] TRUE
>