It seems division with numbers bigger than 10 000 000 doesn't work 20000000/21 [1] 952381
55555555/23
[1] 2415459 Thank you
5 messages · bogdanno, (Ted Harding), Gavin Simpson +2 more
It seems division with numbers bigger than 10 000 000 doesn't work 20000000/21 [1] 952381
55555555/23
[1] 2415459 Thank you
It seems division with numbers bigger than 10 000 000 doesn't work 20000000/21 [1] 952381
55555555/23
[1] 2415459 Thank you
I think you are confusing what is displayed with what is computed: 20000000/21 # [1] 952381 print(20000000/21,17) # [1] 952380.9523809524 55555555/23 # [1] 2415459 print(55555555/23,17) # [1] 2415458.913043478 (20000000/21)*21 # [1] 2e+07 print((20000000/21)*21,17) # [1] 2e+07 (55555555/23)*23 # [1] 55555555 print((55555555/23)*23,17) # [1] 55555555 Your "numbers bigger than 10 000 000" corresponds to the default display of results to 7 significant figures. If (as in the above print() statements) you increase this, you get more "reasonable"-looking results. Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 03-May-09 Time: 10:11:02 ------------------------------ XFMail ------------------------------
It seems division with numbers bigger than 10 000 000 doesn't work 20000000/21 [1] 952381
55555555/23
[1] 2415459 Thank you
You are confusing the 'printed' representation of the resulting object with the object itself:
print(20000000/21, digits = 20)
[1] 952380.9523809524 G
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
It seems division with numbers bigger than 10 000 000 doesn't work 20000000/21 [1] 952381
55555555/23
[1] 2415459 Thank you
Hi bogdanno First of all look this
all.equal(21*20000000/21,20000000)
[1] TRUE So de division work correctly but if I type
all.equal(952381*21,20000000)
[1] "Mean relative difference: 5e-08" It's not means R division don't work correctly if you use the command
format(20000000/21,digits=22)
[1] "952380.952380952 So the result: 952381 is a round number not a real result of division. This occur because R print only 7 significants digits in numbers, if you test
all.equal(21*952380.952380952,20000000)
[1] TRUE
Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil
"TH" == Ted Harding <Ted.Harding at manchester.ac.uk>
on Sun, 03 May 2009 10:11:04 +0100 (BST) writes:
>> It seems division with numbers bigger than 10 000 000
>> doesn't work 20000000/21 [1] 952381
>>> 55555555/23
>> [1] 2415459
>>
>> Thank you
TH> I think you are confusing what is displayed with what is
TH> computed:
TH> 20000000/21 # [1] 952381 print(20000000/21,17) # [1]
TH> 952380.9523809524
TH> 55555555/23 # [1] 2415459 print(55555555/23,17) # [1]
TH> 2415458.913043478
TH> (20000000/21)*21 # [1] 2e+07
TH> print((20000000/21)*21,17) # [1] 2e+07
TH> (55555555/23)*23 # [1] 55555555
TH> print((55555555/23)*23,17) # [1] 55555555
TH> Your "numbers bigger than 10 000 000" corresponds to the
TH> default display of results to 7 significant figures.
TH> If (as in the above print() statements) you increase
TH> this, you get more "reasonable"-looking results.
Yes, indeed.
If Bogdanno thinks he wants to always see "all" digits, he
should use something like
options(digits= 20)
in his R startup setting, e.g. in his Rprofile, see ?Startup.
Note however:
Quite a few experienced R users rather do *REDUCE* the default number
of digits printed, rather than enlarge them.
(I don't)
Martin Maechler, ETH Zurich
TH> --------------------------------------------------------------------
TH> E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
TH> Fax-to-email: +44 (0)870 094 0861 Date: 03-May-09 Time:
TH> 10:11:02 ------------------------------ XFMail
TH> ------------------------------