Solid Edge How to compare floating values in Variable Table of a Solid Edge Part?

2021-10-06T23:57:42Z
PART/SHEETMETAL

Summary


Details

Let us assume you want to check if the value of Var1 in variable Table is identical
to the value in Var2. 

You need to know that this is not easy to do for floating values, because the
internal representation in a computer is not always exact (think of the value of
the fraction  1/3, which is periodically 0.333333etc).

So how to compare floating values in Variable Table?




Solution

You can check this easily with the help of the following formula:

X = cbool(abs(Var1-Var2)<0.0001)


If the values from Var1 and Var2 are nearly identical (up to 4 digits after the
decimal point that is defined by the value 0.0001), then the VBScript function
cbool will give a result for X other that is other than 0, which is to be interpreted as
TRUE.

If the result from cbool for X is 0, then this means FALSE, i.e. Var1 differs
from Var2.



Hardware/Software Configuration

Platform: INTL64
OS: windows
OS Version: n/a
Product: SOLID_EDGE
Application: PART/SHEETMETAL
Function: TOOLS

Ref: 002-8520346

KB Article ID# PL8520346

Contents

SummaryDetails

Associated Components

PART/SHEETMETAL: FLAT_PATTERN