Toni Toni - 1 year ago 68
R Question

Which calculation of 2 to the 168th power is correct, and why?

Apropos of this question from Quora, is R off?

With Wofram Alpha:


on Python:


whereas with R:


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.

Answer Source

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)

[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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download