newRPL: [UPDATED April 27-2017] Firmware for testing available for download
|
03-30-2016, 04:43 PM
(This post was last modified: 03-30-2016 04:58 PM by Claudio L..)
Post: #247
|
|||
|
|||
RE: newRPL: [UPDATED Mar-09-16] Firmware for testing available for download
(03-29-2016 05:20 PM)Visitor Wrote: Hello Claudio, I'm glad somebody is actually looking at the code. And understanding it despite my bad coding habits too! Jokes aside, yes, it is intended. Most of those constants are for internal use by the trig and hyperbolic functions, therefore they need some extra precision to guarantee that the final result has enough digits. Case in point: the PI constant is used for argument reduction among other things. If an angle is exactly the same as PI with 32 digits precision, the angle it represents is not exactly PI, but only the first 32 digits of PI. We need the internal PI to have at least twice the digits, so that when subtracting PI0-angle we get at least 32 significant digits for the angle we'll be using as input to SIN or COS to have any meaning. For example: π0 SIN gives a meaningless result, because the input is too close to PI at double precision, and the system fails to produce an accurate result. EDIT: That result is not totally meaningless, it's actually accurate up to a few guard digits (usually 8). Just do π0 SIN π0 GETPREC 2 * SETPREC π0 - + and you'll get that only the first 8 digits were correct. The Pi0 constant was exposed to the user for those corner cases. Quite often you need PI at a higher precision than normal so subtractions work well for angles near PI. Notice the 0 in the name, to make it different from the regular PI constant. As you noticed, operations will round the result to the system precision, and that's the important part: it's the result that's rounded, but never the arguments! The operation will take place using the arguments as given, only the final result will be rounded. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)