Student Support Forum: 'Question about Precision' topicStudent Support Forum > General > "Question about Precision"

 Help | Reply To Topic
 Author Comment/Response thedarjeeling 02/06/12 11:35pm What I am trying to do is force Mathematica to round off to a certain precision. To give an example of what I am talking about; let's say y = 0.206. If the precision I desire is 2, I want mathematica to FORCE y to be 0.21 and remember it exactly as that. Currently however, the only methods I have are insufficient. When I use SetPrecision[y,2], it certainly displays 0.21 as it should. But when I add y + y, it becomes 0.41, because mathematica is actually remembering that y had more significant digits originally. I want mathematica to forget the 0.006 ever existed. I want it to internally remember y as SetPrecision[y,2] displayed externally. Yes, I'm aware of the rounding function which gets rids of extra digits, but this is also an insufficient solution because the rounding is static to a certain multiple of a digit, like 0.001 or whatever you set it to. The problem with that is, I want mathematica to round not to a fixed digit, but to a fixed precision. In other words, I want a simple function that would round both 0.206 and 0.000000206 to 0.21 and 2.1 x 10^(-7) respectively. If I use the round function, I'd have to set a certain digit which would screw up the other number. What I'm looking for is some sort of SetPrecision that ACTUALLY FORCES whatever it's setting internally to that level of precision, and forget any extra digits ever existed. URL: ,
 Help | Reply To Topic