![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB Enhancement Requests and Suggestions » View Thread |
Messages 1 to 6 of 6 total |
![]() |
Fri, Mar 14 2014 5:54 PM | Permanent Link |
Barry | Why is:
select Trunc(1.8888,2) producing: 1.89? Shouldn't it be 1.88? It looks like it is rounding the number to 2 decimal places as if I had executed Round(1.8888,2) . Also I noticed there is no Frac() function. I know I can write a function to do it, but I thought there should be a Frac() since it is the opposite of Trunc(). Maybe Tim doesn't give a Frac? (Sorry Galactica fans, I just had to throw it in, even though it is misspelled I couldn't resist. I hope I don't get tossed from the forum!). Barry |
Sat, Mar 15 2014 1:09 AM | Permanent Link |
Adam Brett Orixa Systems | No idea about the reason for the first question ... likely it is the ISO standard, as that is the usual reason (
![]() Like the second question. |
Wed, Mar 19 2014 10:18 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Barry,
<< select Trunc(1.8888,2) > > producing: 1.89? Shouldn't it be 1.88? It looks like it is rounding the number to 2 decimal places as if I had executed Round(1.8888,2) . >> It's a bug. << Also I noticed there is no Frac() function. I know I can write a function to do it, but I thought there should be a Frac() since it is the opposite of Trunc(). >> It's just not something that is normally included in the base function set in SQL. Tim Young Elevate Software www.elevatesoft.com |
Tue, Mar 25 2014 12:01 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Barry,
Actually, this incident report's fix broke this incident report's regression test: http://www.elevatesoft.com/incident?action=viewrep&category=edb&release=2.11&incident=3682 So, it looks like I've got a floating-point approximation issue here that isn't going to get solved completely unless I figure out a different way of truncating floats. The other alternative is to CAST your floats to DECIMAL before calling the TRUNC() function (4 decimal places or less). Tim Young Elevate Software www.elevatesoft.com |
Tue, Mar 25 2014 5:04 PM | Permanent Link |
Barry | Tim,
How about: EXECUTE IMMEDIATE 'CREATE FUNCTION "MyTrunc" (IN "aNum" FLOAT, IN "aNumDec" INTEGER) RETURNS FLOAT BEGIN declare _Fact Integer Default 0; declare _Result Float default NULL; set _Fact = Power(10, aNumDec); set _Result = Trunc(aNum * _Fact) / _Fact; Return _Result; END VERSION 1.00'; Barry |
Wed, Apr 2 2014 7:03 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Barry,
<< How about: >> What about it ? BTW, as you already know, I fixed the issue by using an epsilon to fix the approximation issues. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Wednesday, August 14, 2024 at 03:12 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |