سؤال

How can I transform a value like OxFF to short and long types. is there a standard function for this use?

هل كانت مفيدة؟

المحلول

JavaScript only knows about numbers which are floats.

You can use parseInt to parse that string into an integer.
It really is going to be a float but without a fraction.


Either pass the radix 16 or let JavaScript autodetect it:

parseInt("0xFF", 16)
parseInt("0xFF")

http://jsfiddle.net/bikeshedder/wVRh2/

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top