Ciao a tutti,
I am making a small program to generate quotes.
I have the problem of displaying 4 decimal places in the single piece price. I have tried searching the net if there is a solution, but I have not found it.
Is it possible or is it one of those basic functions that should be considered and implemented?
Unfortunately there is no way to limit number of decimals directly in the label. However there are some workarounds
If you set up your number (magic text properties) to be displayed as “currency”, it will always add the currency sybmol(s) and it will always add 2 decimal digits.
You can also use a custom formula like this: INT (price * 100) / 100. It won’t always display 2 decimals, but it will remove extra decimals. By the way if you need 4 decimals it will look like INT (price * 10000) / 10000. INT may be replaced by ROUND here
Another option is to split decimals and whole numbers and put 2 labels. To get a whole number, you will need to use a formula INT (price). To get the decimal part, the formula will be more complex:
INT ( ( price - INT (price) ) * 100 ). INT can’t be replaced by ROUND in INT(price)
Let’s take an example: we have the price of 125,67.
INT (price) = 125.
( price - INT (price)) = 125,67 - 125 = 0,67.
( ( price - INT (price) ) * 100 ) = 0,67 * 100 = 67. This number could be displayed as cents.
And we apply another INT just to be sure to get rid of some unexpected extra decimals.