PLUS+1 Software > General controls

Decimal Values

(1/1)

Emerson Zaionc:
Hello guys;
Could you answer me if you can use this value in the image described as 'True Value'. I need to work with decimal values and I do not know how to do it. Today I'm working with 'False Value', but I need more precision.
Can you help me?

Jakob:
Hi,
What I usually do is to scale up the value before the division.
Meaning first multiply with 10000 and then divide by 21 (or what ever value you need).

I hope that helps

/Jakob

Emerson Zaionc:
Could you put a picture as an example?

spittet:
Taken from your example above :

10/6 = 2 (should be 1.67)

Assuming you want 2 decimal precision, then you should do the following :

10 x 100 = 1000 --> 1000/6 = 166. Then, you need to remember that this number (166) is 1.66 x 100. The next step would be to extract the integer part and the decimal part of this number to have 2 other numbers : 1 and 66. Then, in a text component, you can input the "1" as the integer part and the "66" as the decimal part after the point. to show the real number as "1"."66" .

Remember that you cannot use floating point values in PLUS1. They are all integers.

Also, make sure to use 16-bit or 32-bit data type because the first multiplication (by 100 or 1000) can increase the output a lot and you can fall into an overflow.

Sam

Navigation

[0] Message Index

Go to full version