Issue Details (XML | Word | Printable)

Key: CORE-2282
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Claudio Valderrama C.
Reporter: Paul Vinkenoog
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird Core

*truncate UDFs broken for numbers below -1

Created: 18/Jan/09 10:34 PM   Updated: 23/Feb/11 09:45 AM
Component/s: UDF
Affects Version/s: 1.5.5, 2.0.4, 2.1.1
Fix Version/s: 2.5 Beta 1, 2.1.3, 1.5.6, 2.0.6

Time Tracking:
Not Specified

Planning Status: Unspecified


 Description  « Hide
For numbers below -1, *truncate returns the nearest lower number (e.g. -2.1 -> -3; -45.88 -> -46). This is 'floor' rather than 'truncate'.

On <-1, 0], truncate returns 0.
Only -1 truncates to -1.
(The last two results are correct; just given here for completeness.)


 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Claudio Valderrama C. added a comment - 21/Jan/09 06:41 AM
Since this problem was reported privately by Paul Vinkenoog privately to me months ago but I didn't have time to fix it until recently and he put the tracker item when I showed it a change fbudf, I'm going to commit the same code in all affected branches. Not necessarily what Paul wanted, since round and trunc in fbudf were mean to be asymmetric like in the math definition (unlike Delphi functions).
round always rounds to the next bigger integer when it's in the upper half of the range (including x.5).
trunc always truncates to the biggest integer that's equal or smaller than the argument.