Symbolica How to round expression to certain desired decimal places?

2021-10-06T23:26:04Z
Symbolica

Summary


Details

How to round expression to certain desired decimal places? 



Solution

There are two methods to accomplish this:


Method #1: 
Starting with an expression below: 
TEST = 3.2563256984


Now create an expression that will produce the rounding to specific decimal place: 
TEST_ROUND = round((TEST)*1000)/1000




Hint: 
1000 - For 3 decimal places 
100 - For 2 decimal places 
10 - For 1 decimal place


Method #2: 
Start with an expression below: 
TEST = 3.2563256984; this is the original expression with lengthy decimal 
places. 
TEST_ROUND <-- this will be the desired rounded result of TEST.


To obtain TEST_ROUND, create the following expression in this order: 
N = 2 <--this is to indicate how many decimal places desired 
a = (TEST-trnc(TEST))*10^N 
b = if(a-trnc(a)>=.50000000000)(ceil(a))else(floor(a)) 
TEST_ROUND = trnc(TEST)+b*10^N 



Notes and References





Hardware/Software Configuration

Platform: INTL64
OS: window
OS Version: 764SP1
Product: NX
Application: DESIGN
Version: V9.0.3
Function: EXPRESSION

Ref: 001-8965268

KB Article ID# PL8965268

Contents

SummaryDetails

Associated Components

Symbolica