How to use % in an arithmetic combinator?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
User avatar
WIZ4
Fast Inserter
Fast Inserter
Posts: 209
Joined: Thu Apr 07, 2016 1:36 pm
Contact:

How to use % in an arithmetic combinator?

Post by WIZ4 »

I do not understand how percent works in an arithmetic combinator. Please explain me
My native language is russian. Sorry if my messages are difficult to read.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to use % in an arithmetic combinator?

Post by DaveMcW »

42 ÷ 10 = 4 remainder 2

42 / 10 = 4
42 % 10 = 2

User avatar
WIZ4
Fast Inserter
Fast Inserter
Posts: 209
Joined: Thu Apr 07, 2016 1:36 pm
Contact:

Re: How to use % in an arithmetic combinator?

Post 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
dcg7dYi4OkE.jpg (54.11 KiB) Viewed 5547 times
Screenshot_2.png
Screenshot_2.png (106.28 KiB) Viewed 5547 times
My native language is russian. Sorry if my messages are difficult to read.

User avatar
WIZ4
Fast Inserter
Fast Inserter
Posts: 209
Joined: Thu Apr 07, 2016 1:36 pm
Contact:

Re: How to use % in an arithmetic combinator?

Post by WIZ4 »

DaveMcW wrote:42 ÷ 10 = 4 remainder 2

42 / 10 = 4
42 % 10 = 2
Why is not 10% coming output?
Screenshot_2.png
Screenshot_2.png (203.84 KiB) Viewed 5541 times
Screenshot_3.png
Screenshot_3.png (118.7 KiB) Viewed 5541 times
My native language is russian. Sorry if my messages are difficult to read.

Dimanper
Inserter
Inserter
Posts: 47
Joined: Sat Sep 17, 2016 9:50 am
Contact:

Re: How to use % in an arithmetic combinator?

Post 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).

User avatar
hitzu
Filter Inserter
Filter Inserter
Posts: 530
Joined: Tue Sep 09, 2014 5:55 pm
Contact:

Re: How to use % in an arithmetic combinator?

Post 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.
Это остаток от деления, а не проценты.

nevniv
Inserter
Inserter
Posts: 49
Joined: Wed Sep 21, 2016 1:37 am
Contact:

Re: How to use % in an arithmetic combinator?

Post 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

Serenity
Smart Inserter
Smart Inserter
Posts: 1000
Joined: Fri Apr 15, 2016 6:16 am
Contact:

Re: How to use % in an arithmetic combinator?

Post by Serenity »

It's not a percentage. It's called modulo:

https://en.wikipedia.org/wiki/Modulo_operation

User avatar
hitzu
Filter Inserter
Filter Inserter
Posts: 530
Joined: Tue Sep 09, 2014 5:55 pm
Contact:

Re: How to use % in an arithmetic combinator?

Post 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.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: How to use % in an arithmetic combinator?

Post 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)

Zonk
Long Handed Inserter
Long Handed Inserter
Posts: 54
Joined: Tue Jul 12, 2016 12:05 pm
Contact:

Re: How to use % in an arithmetic combinator?

Post 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

User avatar
WIZ4
Fast Inserter
Fast Inserter
Posts: 209
Joined: Thu Apr 07, 2016 1:36 pm
Contact:

Re: How to use % in an arithmetic combinator?

Post by WIZ4 »

I understand, thanks for explaining
My native language is russian. Sorry if my messages are difficult to read.

Post Reply

Return to “Gameplay Help”