From ru|pb@rr@d@@ @end|ng |rom @@po@pt  Sun Jul 10 20:46:26 2022
From: ru|pb@rr@d@@ @end|ng |rom @@po@pt (Rui Barradas)
Date: Sun, 10 Jul 2022 19:46:26 +0100
Subject: [Rd] Floating point issue
In-Reply-To: <CALEXWq3F86UV71qzWaUHrZkZb9k8dC2H_OR_cYqzvEf6pFz9hA@mail.gmail.com>
References: <CAEKh8uhNTF3RczavV-jh82tK9e=iDr2tzys=wGSk6ZD5e2tndg@mail.gmail.com>
 <25290.56745.942106.634125@rob.eddelbuettel.com>
 <cb4678b2d846400194e23034c6cf7674@chu-rouen.fr>
 <CALEXWq3F86UV71qzWaUHrZkZb9k8dC2H_OR_cYqzvEf6pFz9hA@mail.gmail.com>
Message-ID: <a48ab1cd-43b5-0810-2a29-3b0e892b3d00@sapo.pt>

Hello,

R 4.2.1 on Windows 11, sessionInfo() at end.

I cannot reproduce this either.


op <- options(scipen = 999)

1e24
# [1]  999999999999999983202404
1e24 == 999999999999999983222784
# [1] TRUE

1e25
# [1] 10000000000000000906640224
1e25 == 10000000000000000905969664
# [1] TRUE

10000000000000000905969664
# [1] 10000000000000000906640224

10000000000000003053453312
# [1] 10000000000000003053648442

10000000000000000000000000 == 1e25
# [1] TRUE

options(op)

sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8 
LC_CTYPE=Portuguese_Portugal.utf8
[3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C 

[5] LC_TIME=Portuguese_Portugal.utf8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.2.1


Hope this helps,

Rui Barradas

?s 15:44 de 10/07/2022, I?aki Ucar escreveu:
> On Sun, 10 Jul 2022 at 16:28, GILLIBERT, Andre
> <Andre.Gillibert at chu-rouen.fr> wrote:
>>
>>> No, that is how computers work (with floating point numbers).
>>
>>
>> The fact that not all values are representable by floating point does not mean that outputing a number with maximum accuracy, then reading it back, should yield a different number.
>>
>>
>> I would like to point that I cannot reproduce this "bug" on the official R 4.2.0 Windows x86_64 build on an AMD Ryzen 1700 on Windows 10.
> 
> I cannot reproduce this on a 64-bit Linux build of R 4.1.3 either:
> 
> options(scipen = 999)
> 1e24
> #> [1]  999999999999999983222784
> 1e24 == 999999999999999983222784
> #> [1] TRUE
> 
> 1e25
> #> [1] 10000000000000000905969664
> 1e25 == 10000000000000000905969664
> #> [1] TRUE
> 
> 10000000000000000905969664
> #> [1] 10000000000000000905969664
> 
> 10000000000000003053453312
> #> [1] 10000000000000003053453312
> 
> 10000000000000000000000000 == 1e25
> #> [1] TRUE
>



[Rd] Floating point issue
Rui Barradas