NavList:
A Community Devoted to the Preservation and Practice of Celestial Navigation and Other Methods of Traditional Wayfinding
Re: Sun semidiameter
From: Paul Hirose
Date: 2007 Apr 15, 19:48 -0700
From: Paul Hirose
Date: 2007 Apr 15, 19:48 -0700
Alexandre E Eremenko wrote: > > The reason of these errors is probably the rounding > subroutine. To get the last digit really true, > yoiu have to do all computations with one more digit, > and then apply an exact rounding algorithm, while > in most cases they just cut off the last digit > instead. Because nobody really cares about the exactness > of the > decimal minute digit. Generally, programming languages don't provide any way to carry one more digit in computations. You can control precision in a coarse manner by the choice of data type, e.g., single precision or double precision floating point. But the machine stores and computes that type to full accuracy, whether you need it or not. On output you can specify precision. In all the C family languages I've used, floating point output is rounded. For example, if you print pi to three decimal places, the result is 3.142, not 3.141. This control over precision only affects the output formatting, though. To reduce the precision of the variable itself, the Microsoft .NET Framework (accessible with Visual Basic, Visual C#, et al) has routines to round a value to a specified number of decimal places: http://msdn2.microsoft.com/en-us/library/system.math.round.aspx But since that's extra work for the machine, normally you'd round only the human-readable output, and maintain variables to full precision. Astronomical computing has changed a lot since the days when "computers" were human beings running desk calculators. Nowadays even a cheap machine has a floating point processor in the CPU. Many of the old labor saving methods disappeared because on today's hardware there's no penalty for carrying extra significant digits. -- I block messages that contain attachments or HTML. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to NavList@fer3.com To , send email to NavList-@fer3.com -~----------~----~----~----~------~----~------~--~---