Calculation Symbol

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

JDR04
Posts: 264
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Calculation Symbol

Postby JDR04 » Sun Jan 14, 2018 11:48 pm

When using the CALCULATION SYMBOL I would like to know what the line ;

Duty = Duty * 53/100 means and its influence please. I have attached a screen grab as well. Thanks folks.....John
Attachments
Calculation Symbol 2.jpg
Calculation Symbol 2.jpg (64.95 KiB) Viewed 1796 times

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Calculation Symbol

Postby kersing » Sun Jan 14, 2018 11:59 pm

This looks like a question that can use some context.

In you diagram the line simply means the variable duty is multiplied by 53 and then divided by 100. (Which will not yield the result you expect because the multiplication overflows the byte [0-255 value range] variable (5 * 53 = 265 which results in duty becoming 10)

What duty does in your code we can't guess because we there is no flowchart...
These users thanked the author kersing for the post (total 2):
JDR04 (Mon Jan 15, 2018 11:20 pm) • jgu1 (Sat Jan 20, 2018 7:36 am)
Rating: 10.53%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

JDR04
Posts: 264
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Calculation Symbol

Postby JDR04 » Mon Jan 15, 2018 9:22 pm

Thanks for replying.Here is the flow chart in question.
Thanks for your help////John
Attachments
16F690 PWM EXP.fcf
(13.53 KiB) Downloaded 57 times

JDR04
Posts: 264
Joined: Tue Mar 05, 2013 10:49 pm
Has thanked: 111 times
Been thanked: 13 times
Contact:

Re: Calculation Symbol-Is this Correct?

Postby JDR04 » Thu Jan 18, 2018 10:13 pm

OK.could somebody tell me if I'm right or wrong please.

When using the calculation ,Duty=5*53/100 should be Duty=5*51/100

So my assumption is that whatever your Duty number is it should not be multiplied by anything that results in a number bigger than 255?

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: Calculation Symbol

Postby medelec35 » Thu Jan 18, 2018 11:22 pm

Hi John,
Since a byte is maximum value is 255, then:

Code: Select all

255 + 1 = 0

Another example:

Code: Select all

255+ 5 = 4
etc.
Also

Code: Select all

0 - 1  = 255

That's why the result of a byte can't be greater than 255.
If it is, then unexpected results will be seen.
So Jac is correct but only if /100 was not used after.

You can have intermittent value within a calculation higher than 255.
It could be as high as 32767 as singed integers are used as temporary variables.
So long as final result is not greater than 255.
For your example:

Code: Select all

Duty=5*53/100

Is allowed as the final result will be 2:

Code: Select all

5 * 53 = 265
265 / 100 = 2.65
= 2

Note:
Numbers are not rounded up, so 2.65 will round down to 2

Martin
These users thanked the author medelec35 for the post (total 2):
jgu1 (Sat Jan 20, 2018 7:35 am) • JDR04 (Thu Jan 25, 2018 6:27 pm)
Rating: 10.53%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.