For example, if I have a network spec like 172.20.10.0/24, ’24’ is the bitcount. What’s the best way to convert that to a netmask like 0xffffff00 ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why waste time with subtraction or ternary statements?
If you know your integer is exactly 32 bits long then you only need to type 0xffffffff once.
Both compile to the exact same assembly code.