Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7537883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:58:13+00:00 2026-05-30T06:58:13+00:00

I am trying to understand javascript octal and hexadecimal computations. I know I can

  • 0

I am trying to understand javascript octal and hexadecimal computations. I know I can use parseInt(string, radix) to get the Integer value.

For example, when I try this why are the values different?

var octal = parseInt('026', 8); 
var octal1 = parseInt('030', 8); 
alert(octal); //22
alert(octal1); //24    

var hex = parseInt('0xf5', 16); 
var hex1 = parseInt('0xf8', 16); 
alert(hex); //245
alert(hex1); //248

But if I try to save it in an array why are the answers different and incorrect?

var x = new Array(026, 5, 0xf5, "abc");
var y = new Array(030, 3, 0xf8, "def");

alert('026 is ' + parseInt(x[0],8)); //18
alert('0xf5 is ' + parseInt(x[2],16)); //581
alert('030 is ' + parseInt(y[0],8)); //20
alert('0xf8 is ' + parseInt(y[2],16)); //584
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:58:14+00:00Added an answer on May 30, 2026 at 6:58 am

    parseInt converts the argument to string before parsing it:

    1. Let inputString be ToString(string)

    So:

    0x35.toString() // "53"
    parseInt( "53", 16 ); //83
    parseInt( 0x35, 16 ); //83
    

    What you have in your arrays are mostly already numbers so there is no need to parse them. You will get expected results if you change them to strings:

    var x = new Array("026", "5", "0xf5", "abc");
    var y = new Array("030", "3", "0xf8", "def");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to understand how to use firebug to debug my Javascript. So I
I'm trying to understand when to use anonymous JavaScript functions. State differences between the
I'm still trying to get to understand how Javascript is wrapped in Seaside, say
I don't really know anything about Javascript and I am trying to understand this
I have this javascript function I am trying to understand. I don't know if
I am trying to understand how a single and multidimensional javascript array would appear
I'm trying to understand how to build a JSON object in JavaScript. This JSON
I am trying to understand JavaScript minification and compression processes and have couple of
I'm really confused here. I am trying to understand this code (it's javascript) but
Possible Duplicate: JavaScript: Class.method vs. Class.prototype.method I am trying to understand object in JavaScript.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.