2

Apropos of this question from Quora, is R off?

With Wofram Alpha:

374144419156711147060143317175368453031918731001856

on Python:

374144419156711147060143317175368453031918731001856

whereas with R:

374144419156711147080244462828666486484022626226666

I am sure that there is an explanation that is obvious if you understand the numerical computer complexities in the linked post. Otherwise, I don't see why a reader's digest explanation applied to this very specific question can't be answered as an independent post.

Antoni Parellada
  • 4,253
  • 6
  • 49
  • 114
  • 1
    Just curious, how did you get this result in R? – Rich Scriven Oct 23 '16 at 00:13
  • @RichScriven > options(scipen=99) > 2^168 [1] 374144419156711147080244462828666486484022626226666 – Antoni Parellada Oct 23 '16 at 00:15
  • 1
    I get `374144419156711147060143317175368453031918731001856`. Are you on a 32 bit machine? Posting the result of `Sys.info()` would be helpful. – Rich Scriven Oct 23 '16 at 00:16
  • @RichScriven Sorry, dealing with the harassing from the non-paid "closers"... Here: > Sys.info() sysname release version nodename machine "Windows" ">= 8 x64" "build 9200" "JANOTEBOOK" "x86" login user effective_user – Antoni Parellada Oct 23 '16 at 00:24

1 Answers1

1

It works for me...

> format(2^168,scientific = FALSE)
[1] "374144419156711147060143317175368453031918731001856"
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.12 (Sierra)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
[1] tools_3.3.1

I think your issue is using scipen.

scipen: integer. A penalty to be applied when deciding to print numeric values in fixed or exponential notation. Positive values bias towards fixed and negative towards scientific notation: fixed notation will be preferred unless it is more than scipen digits wider.

akaDrHouse
  • 2,190
  • 2
  • 20
  • 29