Recent

Author Topic: rounding in lazreport  (Read 2013 times)

slai

  • New Member
  • *
  • Posts: 25
rounding in lazreport
« on: January 31, 2013, 08:28:17 pm »
hy

i've got a value of 175.1246, so if i do Variable Format, in the Context-Menu of lazreport designer, and set it to numeric -> decimal digits 2, it rounds to 175.12.

This is, in my opinion, not the value you've to get. It should be 175.13 because of the 6->makes->5->makes->3.
Does anyone have the same behaviour. Also try it out directly from a Dataset or From a Variable in LazReport.

thx for reply and trying out!

ps: Lazarus 1.0.4 FPC 2.6 from sourceforge directly (so no trunk branch). Database: Firebird 2.1.5

jujibo

  • Jr. Member
  • **
  • Posts: 77
Re: rounding in lazreport
« Reply #1 on: January 31, 2013, 08:36:49 pm »
The result you get is correct.

There are different rounding methods. Lazarus+FreePascal use Banker's Rounding system  (by default). There are also Half Up and Half Down rounding...

http://lazarus-ccr.sourceforge.net/docs/rtl/system/round.html

175.1246 scaled to 2 decimals is 175.12  because 4 is lower than 5 or 46 is lower than 50

More about rounding:

http://en.wikipedia.org/wiki/Rounding
« Last Edit: January 31, 2013, 08:38:56 pm by jujibo »