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.
Understanding Calculation
Moderator: Benj
-
- Valued Contributor
- Posts: 1191
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: Understanding Calculation
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
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