I want to do a simple division i.e. 0.70524/0.51824 . What I want is to find the result of the roundation of this division for precision from 1 to 19 decimal digits. So what I do is:

For[i = 1, i < 19, i++, Print[N[Round[0.70524/0.51824, 10^-i], i+1]] ]

So I get the following 19 values. 1.4 1.36 1.361 1.3608 1.36084 1.360837 1.3608367 1.36083668 1.360836678 1.3608366780 1.36083667799 1.360836677987 1.3608366779870 1.36083667798703 1.360836677987033 1.3608366779870330 1.36083667798703280 1.360836677987032832 1.3608366779870328832

But as you can see after the 17th loop the results are wrong. If you round 1.360836677987032832 to 17 digits you should get 1.36083667798703283 but you get 1.36083667798703280. What do I do wrong? Is there a solution to that? Isn't it the same as in the case of N[1/3, 20] where I get correct results?


closed as off-topic by Daniel Lichtblau, m_goldberg, Alexey Popkov, Niki Estner, Henrik Schumacher Nov 17 '18 at 7:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, m_goldberg, Alexey Popkov, Niki Estner, Henrik Schumacher
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ You are doing arithmetic on machine doubles, and that works at about 16 digits. You cannot get more digits after the fact. $\endgroup$ – Daniel Lichtblau Nov 15 '18 at 16:27
  • $\begingroup$ But the answer of Rohit Namjoshi is working. You say that these values are not correct? $\endgroup$ – Alex Spanos Nov 15 '18 at 16:36
  • 2
    $\begingroup$ I made no such claim (I did not comment on that response). Take another look at that code. In contrast to yours, it is doing division on exact values. $\endgroup$ – Daniel Lichtblau Nov 15 '18 at 16:41
For[i = 1, i < 19, i++, Print[N[Round[70524/51824, 10^-i], i + 1]]]
  • $\begingroup$ Do you know why my code isn't working? I mean it is the same division. Thank you very much in advance! $\endgroup$ – Alex Spanos Nov 15 '18 at 16:08
  • $\begingroup$ @AlexSpanos See @Daniel's comment above. For more details on why 0.70524/0.51824 is not the same as 70524/51824see this $\endgroup$ – Rohit Namjoshi Nov 15 '18 at 16:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.