Iscript Function Trunc() Precision Not Working (Doc ID 557726.1)

Last updated on SEPTEMBER 26, 2016

Applies to:

Oracle Communications Billing and Revenue Management - Version 7.3.0.0.0 and later
Information in this document applies to any platform.
***Checked for relevance on 01-May-2010***
Checked for relevance on 28-Nov-2011


Symptoms

The trunc() function does not work on Decimal variables in iScript and iRule scripts that a user has created following BRM documentation :

In the iScript, the following code was added:

logFormat( "grant unit before trunc = " + decimalToStr(percent) );
percent_trunced = trunc(percent, 2);
logFormat( "grant unit after trunc = " + decimalToStr (percent_trunced) );


In the corresponding log file, the user got :

09.01.2008 16:22:57 myhost ifw IFW NORMAL [T:7] 00387 -
(ifw.Pipelines.DiscountPipeline0.Functions.Standard.FunctionPool.RealtimeDiscountPercent.Module.Scri
pts.RealtimeDiscountDsc) grant unit before trunc = 5.000000
09.01.2008 16:22:57 myhost ifw IFW NORMAL [T:7] 00387 -
(ifw.Pipelines.DiscountPipeline0.Functions.Standard.FunctionPool.RealtimeDiscountPercent.Module.Scri
pts.RealtimeDiscountDsc) grant unit after trunc = 5.000000


Also the user tried passing only the variable percent to trunc without specifying the number of digit to truncate to (so that it will take the default zero as the document suggests). Neither option worked.

Steps to Reproduce :
1) Declare a Decimal variable, say x.
2) Assign x with a value of 5 digits after the decimal point, say, 5.00000.
3) call trunc(x, 2) in an iScript
4) log the value of x before and after the trunc call with logFormat
5) Examine the log file.
6) It will show that x is not truncated after the trunc() call.

.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms