[Flightgear-devel] rounding and truncation (was: Textranslate Step and Scroll)

2007-02-07 Thread John Denker
On 02/07/2007 12:26 PM, Ron Jensen wrote: How would the step function know to round to the proper number of decimal places? In the 2D instruments a printf-style statement is used, i.e. format%02.2f/format. However, we're not exactly printing in textranslate. I thought about a

[Flightgear-devel] rounding and truncation

2007-02-07 Thread John Denker
On 02/07/2007 02:14 PM, Andy Ross wrote: The patch itself looks sane and easy. But I think I agree with John, this is a workaround for a design flaw in the step animation that we should just fix. :-) So you want to pass in the floating point value 29.92 and a step of 10 and get back

Re: [Flightgear-devel] rounding and truncation

2007-02-07 Thread John Denker
Improved code. Previous version went against the POSIX convention. # Following the POSIX convention, # halfway cases are rounded away from zero, # to the extent this is possible given the inherent # inexactitude of the floating-point representation. round = func(arg, quantum=1){ if (quantum