Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.6K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Difference between N[1/3, 2] -vs- N[1./3., 2]?

Can you please neatly explain why the following two commands give different outputs?

N[1/3, 2]

0.33

N[1./3., 2]

0.333333

Thank you!

4 Replies

Kuba, Sander, Murray, thank you for your responses. Please browse the attached file. I understand that using "Round" is the correct solution. Best!

Attachments:

Or perhaps:

     NumberForm[1./3., 2]
(*  0.33  *)
POSTED BY: Murray Eisenberg
POSTED BY: Sander Huisman
Posted 10 years ago

N ref page 3rd example's note:

With machine-precision input, the results are always machine precision

Workaround:

N[1/3. // Rationalize, 2]
(* 0.33 *)
POSTED BY: Kuba Podkalicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard