In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "javascript how to convert integers to hexadecimal", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "javascript how to convert integers to hexadecimal" bar!
In javascript, you can use the toString () method to convert an integer to hexadecimal, which parses a specified numeric value and returns a string representation of the specified binary, with the conversion syntax of "specify numeric object .toString (16);".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
In javascript, you can use the toString () method to convert integers to hexadecimal.
The toString () method parses the specified numeric value and attempts to return a string representation of the specified cardinality (radix).
Syntax:
NumberObject.toString (radix)
Parameter radix: optional. Specifies the cardinality of the number so that it is an integer between 2 and 36. If this parameter is omitted, the cardinality of 10 is used.
Note: for letters with a cardinality greater than 10, letters represent numbers greater than 9. For example, for hexadecimal numbers (radix 16), use a through F.
Example:
Var num = 255th console.log (num.toString (16))
Take it a step further: convert red, green, and blue integer section values to hexadecimal strings
Var r = 0 return var g = 255 return var b = 255 position function convert (integer) {var str = Number (integer) .toString (16); return str.length = = 1? "0" + str: str;}; function to_rgb (r, g, b) {return "#" + convert (r) + convert (g) + convert (b);} var color = to_rgb (r, g, b); console.log (color)
Thank you for your reading, the above is the content of "javascript how to convert integers to hexadecimal". After the study of this article, I believe you have a deeper understanding of how javascript converts integers to hexadecimal, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.