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 realize the conversion from octal to decimal in JavaScript

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

Share

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

This article mainly introduces how to convert JavaScript from octal to decimal, which is very detailed and has certain reference value. Friends who are interested must finish reading it!

In JavaScript, you can use the parseInt () function to convert octal numbers to decimal numbers. This function is used to parse strings, and the returned result is a parsed integer. When the parameter is set to 8, you can convert octal to decimal with the syntax of "parseInt (string,8)".

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

How to realize Octal to Decimal in JavaScript

The parseInt () function parses a string and returns an integer.

When the value of the parameter radix is 0, or when it is not set, parseInt () determines the cardinality of the number based on string.

When the parameter radix is omitted, the cardinality of the default number for JavaScript is as follows:

If string starts with "0x", parseInt () parses the rest of the string into hexadecimal integers.

If string starts with 0, ECMAScript v3 allows an implementation of parseInt () to parse subsequent characters into octal or hexadecimal numbers.

If string starts with a number from 1 to 9, parseInt () parses it to a decimal integer.

ParseInt (string, radix)

String is required. The string to be parsed.

Radix is optional. Represents the cardinality of the number to parse. The value is between 2 and 36.

Examples are as follows:

123 [xss_clean] (parseInt ("12", 8))

Output result:

The above is all the contents of the article "how to convert JavaScript from octal to decimal". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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