Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to convert decimal to Octal in JavaScript

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to convert JavaScript from decimal to octal". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In JavaScript, you can use the toString () method to convert decimal to octal, which is used for string representation of numbers. When the parameter is set to "8", the number can be displayed in octal with the syntax "number.toString (8)".

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

How to convert decimal to Octal in JavaScript

JavaScript toString () method

A string representation used for numbers.

For example, when radix is 2, NumberObject is converted to a string represented by a binary value.

Grammar

Number.toString (radix)

Radix is optional. Specifies that the cardinality that represents a number is an integer between 2 and 36. If this parameter is omitted, the cardinality of 10 is used. Note, however, that if the parameter is a value other than 10, the ECMAScript standard allows the implementation to return any value.

2-numbers are displayed as binary valu

8-numbers are displayed as octal valu

16-numbers are displayed as hexadecimal valu

Examples are as follows:

Rookie tutorial (runoob.com) Click the button to display the formatted number

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report