Message Boards Message Boards

0
|
2547 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Digit precision with N command when working with machine precision numbers

Posted 10 years ago

I have something like this:

N[Mean[{3.81913, 243.354}], 3]

It outputs

123.587

because the mean of that list is a Machine Precision number and then, N[ ] does nothing. How can I force Mathematica to show the number of digits I want in a case like this one?

POSTED BY: Daniel Solis
3 Replies

Possibly

N[Mean[Rationalize@{3.81913, 243.354}], 3]

is one way to go.... when you are working with machine precision numbers then machine precision arithmetic is used throughout the calculation.

POSTED BY: David Reiss

SetPrecision[...,3] should do this.

POSTED BY: Daniel Lichtblau

Thanks!, both options worked.

POSTED BY: Daniel Solis
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract