How to convert hexadecimal string to decimal?

。_饼干妹妹 提交于 2019-12-02 13:35:00

问题


I would appreciate it if you could tell me how I can convert hexadecimal letters within an NSString, e.g. @"50A6C2", to decimals using Objective-C. Thanks in advance.


回答1:


The easiest way is to use an NSScanner, specifically the methods scanHexInt: or scanHexLongLong:. Another possibility is to get the C string from the NSString and use C-style functions such as strtol (with base 16).



来源:https://stackoverflow.com/questions/6002196/how-to-convert-hexadecimal-string-to-decimal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!