Page 1 of 1
How to use % in an arithmetic combinator?
Posted: Fri Apr 28, 2017 11:04 pm
by WIZ4
I do not understand how percent works in an arithmetic combinator. Please explain me
Re: How to use % in an arithmetic combinator?
Posted: Fri Apr 28, 2017 11:08 pm
by DaveMcW
42 ÷ 10 = 4 remainder 2
42 / 10 = 4
42 % 10 = 2
Re: How to use % in an arithmetic combinator?
Posted: Fri Apr 28, 2017 11:19 pm
by WIZ4
DaveMcW wrote:42 ÷ 10 = 4 remainder 2
42 / 10 = 4
42 % 10 = 2
What am I doing wrong? Why does not 2 come out?
- dcg7dYi4OkE.jpg (54.11 KiB) Viewed 5669 times
- Screenshot_2.png (106.28 KiB) Viewed 5669 times
Re: How to use % in an arithmetic combinator?
Posted: Fri Apr 28, 2017 11:29 pm
by WIZ4
DaveMcW wrote:42 ÷ 10 = 4 remainder 2
42 / 10 = 4
42 % 10 = 2
Why is not 10% coming output?
- Screenshot_2.png (203.84 KiB) Viewed 5663 times
- Screenshot_3.png (118.7 KiB) Viewed 5663 times
Re: How to use % in an arithmetic combinator?
Posted: Fri Apr 28, 2017 11:31 pm
by Dimanper
WIZ4 wrote:DaveMcW wrote:42 ÷ 10 = 4 remainder 2
42 / 10 = 4
42 % 10 = 2
What am I doing wrong? Why does not 2 come out?
You are calculating 6 % 20, which results in 6 (6 / 20 = 0, remainder 6)
You need to swap them in the combinator to set it to 20 % 6, which results in 2 (20 / 6 = 3, remainder 2).
Re: How to use % in an arithmetic combinator?
Posted: Sat Apr 29, 2017 1:59 am
by hitzu
WIZ4 wrote:I do not understand how percent works in an arithmetic combinator. Please explain me
This is the remainder of the division, not percents.
Это остаток от деления, а не проценты.
Re: How to use % in an arithmetic combinator?
Posted: Sun Apr 30, 2017 12:15 pm
by nevniv
Exactly. If you want 20% of the input you would multiply by .20
6 * .20 = 1.2
If you cannot do decimal, you could do more combinators:
6 * 20 / 100 = 1.2
Re: How to use % in an arithmetic combinator?
Posted: Sun Apr 30, 2017 1:59 pm
by Serenity
Re: How to use % in an arithmetic combinator?
Posted: Sun Apr 30, 2017 2:29 pm
by hitzu
nevniv wrote:Exactly. If you want 20% of the input you would multiply by .20
6 * .20 = 1.2
It's not possible directly with combinators. They operate with integers only. There should be two combinators as in your second example.
Re: How to use % in an arithmetic combinator?
Posted: Sun Apr 30, 2017 4:07 pm
by sparr
hitzu wrote:nevniv wrote:6 * 20 / 100 = 1.2
There should be two combinators as in your second example.
Tip: always multiply before dividing. Integer division causes a loss of precision.
6 * 20 / 100 = 1 (result rounded down from 1.2)
6 / 100 * 20 = 0 (because 6/100 is rounded down to 0 first)
Re: How to use % in an arithmetic combinator?
Posted: Sun Apr 30, 2017 6:21 pm
by Zonk
The % is not PERCENT.
it is like dividing by the givven number and return the remainings. There are only full numbers used like thet:
2 % 2 =0 remaining (2 / 2= 1which is just dumped, )
3 % 2 = 1 remaining (3 / 2 = 1which gets dumped again but now we get 1 remaining)
4 % 2 = 0 remining
Re: How to use % in an arithmetic combinator?
Posted: Sun Apr 30, 2017 7:26 pm
by WIZ4
I understand, thanks for explaining