(Quick note: This post was created with the help of an AI to explain the official Uniface documentation in a simple way.)
Hey everyone! π If you work with Rocket Uniface, you know it's a powerful platform for building enterprise applications. Today, we're going to zoom in on a fundamental building block: the float data type. Understanding it well can save you from some headaches down the road.
What is a Float? π‘
In simple terms, a float is a data type used to store numbers that have a decimal point. Think of prices, measurements, or scientific calculations. Unlike an integer (which holds whole numbers), a float can handle numbers like 123.45 or -0.00789.
How to Use It in ProcScript
You'll declare float variables inside a variables block or as parameters in a params block in your ProcScript code. The syntax is straightforward.
Hereβs a simple example:
variables
float v_pi
float v_price
endvariables
v_pi = 3.14159
v_price = 99.99
putmess "The value of Pi is %%v_pi and the price is %%v_price EUR"
In this snippet, we declare two float variables, assign them values, and then display them in a message box.
The Superpower: Incredible Precision π€―
Hereβs where Uniface really shines. Internally, Uniface supports a massive, platform-independent precision for its float type. We're talking about a precision of 38 digits for the number part (the mantissa) and a four-digit exponent.
This means Uniface can handle incredibly large or incredibly small numbers with high accuracy, regardless of whether you're running on Windows, Linux, or another system.
The Big Catch: Your Database β οΈ
This is the most important part to remember! While Uniface can handle extreme precision internally, the final precision depends on your database management system (DBMS).
For example, you might have a super-precise calculation in your Uniface component. But if you try to store that result in a standard FLOAT column in a SQL database, the database might round or truncate your number to fit its own, less precise data type.
Always be aware of the data type limitations of your target database when working with floats!
Other Cool Features β¨
- Scientific Notation: You can enter values in scientific notation directly into a float field. For example, entering
1.23e-5is perfectly valid and will be treated as0.0000123. - Display Formatting: If you don't specify a display format for a float field in your component, Uniface will use the field's defined syntax length to format how the number is shown to the user.
Conclusion
The float data type in Uniface is more powerful than it might seem at first glance. It offers amazing internal precision, but always remember to check that your database can handle that precision when you store the data.
Happy coding! π
Top comments (0)