# Simple Binary Math - Reset to Zero

#### SAC_CCNP

##### New Member
I am creating a subnet calculator. Binary math. My calculation involves block sizes of 2 to x power. Block size of 2,4,8…128,256. I am doing my work in a column. When the value reaches 256, I need to reset it to 0. The current cell contains previous cell value plus the (absolute value) block size. I.E. =E17+\$E\$2 (=240+16).
What I need is a formula that if the value = 256 to reset to 0.

Last edited:

### Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Give this formula a try...

=MOD(E17+\$E\$2,256)

Genius Mr. Rick Rothstein.

Thank you so very much!

One more simple thing that will assist me in creating some scripting; I need something (I think an array but I don’t know), that produces a result based on the output.

If the value is 128 the result is 127
If the value is 192 the result is 63
Etc.

(just need the formula)

One more simple thing that will assist me in creating some scripting; I need something (I think an array but I don’t know), that produces a result based on the output.

If the value is 128 the result is 127
If the value is 192 the result is 63
Etc.
I do not understand what you are describing that you need to do. Where is the mapping between the numbers you show? How are the number to be input into the program? After the mapping is done, where are the values to be stored at and how do you plan to make use of them? The more details you can provide, the faster you will get an answer.

I do not understand what you are describing that you need to do. Where is the mapping between the numbers you show? How are the number to be input into the program? After the mapping is done, where are the values to be stored at and how do you plan to make use of them? The more details you can provide, the faster you will get an answer.

Thanks Rick, your previous solution provided me exactly the result that I needed.

I had looked at the problem incorrectly (and subsequently described in error).

What I need is a cell that takes my “block size” cell value [A] (2,4,8,16…256) and in the cell with the formula produce the corresponding value (one of the octets of a subnet mask)

Input Result
[A]
16 240
32 224
64 192
[…]

I can complete the work once I see the formula.

Network guy here, not a programmer, formula guy.

Thanks again, very much appreciated

Last edited:

Replies
3
Views
671
Replies
2
Views
672
Replies
1
Views
1K
Replies
2
Views
2K
Replies
9
Views
445

1,196,467
Messages
6,015,401
Members
441,890
Latest member
Liero131313

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back