Display exact value of a variable in R

后端 未结 2 508
南笙
南笙 2020-11-29 13:33
> x <- 1.00042589212565
> x
[1] 1.000426

If I wanted to print the exact value of x, how would I do it?

Sorry if this

相关标签:
2条回答
  • 2020-11-29 13:54
    print(x, digits=15)
    

    or

    format(x, digits=15)
    

    or

    sprintf("%.14f", x)
    
    0 讨论(0)
  • 2020-11-29 14:10

    Globally solution during all the session

    options(digits=16)
    > x
    [1] 1.00042589212565
    

    or locally just for x:

    sprintf("%.16f", x)
    [1] "1.0004258921256499"
    
    0 讨论(0)
提交回复
热议问题