Hey everyone! π If you're working with Uniface, a powerful low-code development platform, you'll often need to handle numbers. Today, let's take a closer look at one of the fundamental data types for this job: numeric.
Let's dive in! πββοΈ
What is the numeric Data Type?
In Uniface, the numeric data type is used to define a number. Think of it as a container specifically designed for holding numerical values.
Here's what makes it special:
- Precision: It can hold a number with up to 38 digits. That's a lot of precision for most calculations! This includes the sign (+ or -) and the decimal point.
- Flexibility: It supports whole numbers, fractions, positive and negative values.
How to Define a numeric Variable
You can define a numeric variable or parameter in your ProcScript code within the variables or params blocks. The syntax is straightforward.
Hereβs an example of how to declare numeric parameters in a component:
params
numeric pPrice, pQuantity, pTotal : IN
endparams
In this snippet, we've defined three parameters (pPrice, pQuantity, and pTotal) that will hold numeric values.
Working with numeric Data β¨
Now for the fun part! You can perform arithmetic operations with numeric variables just like you'd expect. Uniface makes it easy.
Building on our previous example, hereβs how you could calculate a total:
pTotal = pPrice * pQuantity
Easy, right? π
A Few Things to Keep in Mind:
- Scientific Notation: Need to work with very large or small numbers? No problem! The
numerictype accepts scientific notation. For example, you can use a value like123e-5. - How Uniface Calculates: Behind the scenes, Uniface treats numbers as strings during arithmetic operations. It returns the result as a string, truncated at 38 digits.
- Rounding: Uniface automatically handles rounding for you. If the 39th digit of a calculation is 5 or greater, the number is rounded up. This helps maintain accuracy.
Conclusion
The numeric data type is your go-to choice for handling numbers in Uniface. It's robust, precise, and simple to use. Whether you're calculating prices, quantities, or scientific data, numeric has you covered!
Happy coding! π
βοΈ This blog post was created with the help of an AI to ensure clarity and accuracy.
Top comments (0)