Binary Universal Formulas

Source: Internet
Author: User

+ (nsstring*) Changetobinarysystem: (nsstring*) Number {
Nsinteger num = [number intvalue];
Nsinteger remainder = 0;
Nsinteger divisor = 0;
NSString *[email protected] "";
while (num!=0) {
remainder = num%2;
divisor = NUM/2;
num = divisor;
prepare = [Prepare stringbyappendingformat:@ "%ld", remainder];
}
NSString *[email protected] "";
int strlenht = prepare.length%4;
if (strlenht==1) {
result = @ "000";
}else if (strlenht==2) {
result = @ "00";
}else if (strlenht==3) {
result = @ "0";
}
for (Nsinteger i = prepare.length-1; I >= 0;i--) {
result = [result stringbyappendingformat:@ "%@", [Prepare Substringwithrange:nsmakerange (I, 1)]];
}

return result;
}

Binary Universal Formulas

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.