I am working with the R programming language.
I noticed the following:
> 3^83
[1] 3990838394187339732048206468684268226400
> 2^51
[1] 2251799813685248
The problem happens when I try to subtract these two numbers:
> 3^83 - 2^51
[1] 3990838394187339732048206468684268226400
As we can see, the subtraction of these two numbers results in a number that is equal to the bigger number - this is impossible!
Can someone please show me why this is happening and what can I do to correct this error so that the subtraction is correct?
Thanks!
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
> options()$digits
[1] 7
Note : Is it possible that the GMP library (CRAN - Package gmp) might be able to fix this problem?
library(gmp)
num = as.bigz(3)
a=num^96
#a
# Big Integer ('bigz') :
# [1] 6362685441135942358474828762538534230890216321
num1=as.bigz(2)
b=3*(num1^96)
# b
# Big Integer ('bigz') :
# [1] 237684487542793012780631851008
a-b
# Big Integer ('bigz') :
# [1] 6362685441135942120790341219745521450258365313