Page 1 of 1

Understanding Calculation

Posted: Sat Oct 31, 2020 8:14 am
by JUZAR
Hi Sir,

I was just browsing one example of 3 digit seven segment display in FC6. Kindly see attached screen shot of subroutine "Seg2" of voltmeter example. The analog value 23.2365 is allocated to individual digits of by using calculation icon, but I am unable to understand how this calculation is done. Kindly explain how its done.

Regards.

Re: Understanding Calculation

Posted: Sat Oct 31, 2020 9:45 am
by mnf
Hi Juzar,

The key to understand this is that % is mod (or remainder after division) note - this is working on integer maths.

So 13 % 10 = 3

This is used to get the individual digits.

as an example:

31.2 * 10 = 312.
312 % 10 = 2. Get last digit.
31.2 % 10 = 1
31.2 / 10 = 3 // division - again using integer maths

Martin

Re: Understanding Calculation

Posted: Sat Oct 31, 2020 11:33 am
by JUZAR
Thanks Sir for your quick response.