answersLogoWhite

0


Best Answer

JavaScript doesn't come prepared to do much in the way of base changing operations. But the easiest way to get a number to change it's base from decimal to octal is using the Number.toString() method.

Simply assign your decimal value to a variable:

var ourNumber = 10;

Then call the toString() method, passing in the base you want for output as a parameter.

var ourNumberInOctal = ourNumber.toString(8); //yeilds "12"

I've gone ahead and created a complete example at JSFiddle for you. Please see the related link.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a javascript to convert decimal number into octalnumber?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you convert in to a decimal number?

The answer will depend on what you want to convert into a decimal number.


Convert decimal number 12 into hexa decimal number?

It is C


How do you convert 3.27 in to a decimal number?

3.27 is already a decimal number.


How do you convert a fraction to a decimal and then percentage?

To convert a fraction to a decimal divide the numerator (top number) by the denominator (bottom number). To convert a decimal (or fraction) to a percentage multiply it by 100 %.


How do you use a power of ten to convert a decimal to a decimal?

If the number is already in decimal form, you do not need to do anything to "convert" it to decimal!


Explain how to compare a mixed number with a decimal?

Convert the mixed number to a decimal.


How do you divide a decimal by a mixed number?

Convert the mixed number to a decimal and proceed.


How do you convert 6.73 into a decimal?

6.73 is already a decimal number form. You can convert it into fraction as 637/100.


What is 2 58 convert to a decimal?

2.58 is a decimal number.


How do you convert a decimal into a standard number?

with a .


Convert the 71.6 to equivalent decimal number?

It already is a decimal. (Hence the "." in the middle of the number).


How do you convert a mixed fraction into a decimal number?

To convert a mixed number into a decimal, first you must convert the fraction part of the mixed number into decimal form. Do this by dividing the numerator (the top number) by the denominator (the bottom number). Then, place the whole number that was originally part of the mixed number as the whole number for the decimal. For example, let's convert this mixed number into a decimal: 51/4. 1/4 = 0.25 The whole number originally part of the mixed number, 51/4 is 5. Place 5 as the whole number for the decimal. Therefore, the answer is 5.25.