Rounding versus Truncation

I said earlier in the chapter that for numeric fields that allowed truncation of excess fractional digits we would truncate rather than round. However, I realize that there may be business cases for rounding, and doing the rounding in XSLT may not necessarily be the most elegant solution. To add rounding we would need to modify the prepareOutput methods of the DataCellReal and DataCellN classes. To avoid the nastiness of floating point arithmetic I would probably split the source number into an integer and fractional digits. Then I would treat the fractional digits as an integer, rounding up at the appropriate decimal position, truncating, then concatenating the remaining fractional digits to the integer portion on the left of the decimal.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset