This post is part of the series of posts on Tips to Quickly Perform Binary and CIDR Operations. It is borne out of my experience working on ip-num, a typescript library for working with ASN, IPv4, and IPv6 numbers.
This post is about how to quickly calculate exponents with base 2.
Unfortunately I am yet to find a magical tip to use for this task that does not involve having to memorise the result of some calculations, so the core of being able to quickly perform exponents of base 2, involves some memorisation.
Below are the calculations I have come to memorise:
21 = 2
22 = 4
23 = 8
24 = 16
25 = 32
26 = 64
27 = 128
28 = 256
29 = 512
210 = 1024
216 = 65536
The only tip to know is that with each increment of the exponent, the value of the calculation doubles. For example 26 is 64, increasing the exponent by 1, ie 27 leads to 128 which is a doubling of 64.
With this, I can then easily deduce the value of 217 as the double of 65536 which is 131072.
Previous post: How To Tell If Two IP Ranges Are Adjacent
1 comment:
Thanks for sharing this with us. Most of the toppers use tricks to pass this topic.
Post a Comment