954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

What is the function to recognize 8 & 9 as "8" & "9"?

I am working with comparing dates. The problem I am having is that August (08) comes AFTER July (07). However, it seemed to consider Aug (08) and Sep (09) to be earlier than Jan-Jul. When I took a look at the values, they were shown as...

July = "07"
August = "00"
September = "00"

I remember a while back learning that the "default" number system used was the (Oct?) system...0-7 and that there was a function to tell it to recognize the number as coming from a decimal (1-10) system. I just cannot for the life of me remember what that function is.

Any help is greatly appreciated. Thanks.

SnotRockit
:?:

SnotRockit
Newbie Poster
1 post since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

You've not supplied enough information. I'm not familiar with any octal-to-decimal operator, sorry.

Perhaps you could post the relevant code?

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 
I remember a while back learning that the "default" number system used was the (Oct?) system...0-7

The default system is decimal, but if you put a '0' in front of your number it is Octal. But you would need to do your assignments without the string operator for this to take effect.

Read this: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Literals#Integers

Or play with this:

<html>
<body>
<script language="javascript">

document.writeln("08 = " + 08 + "<br/>");
document.writeln("010 = " + 010 + "<br/>");
document.writeln("0x19 = " + 0x19 + "<br/>");
document.writeln("0xFF = " + 0xFF + "<br/>");

var string08 = "08";
document.writeln("string08 = " + string08 + "<br/>");
document.writeln("parseInt(string08, 8) = " + parseInt(string08, 8) + "<br/>");
document.writeln("parseInt(string08, 10) = " + parseInt(string08, 10) + "<br/>");
document.writeln("parseInt(string08, 16) = " + parseInt(string08, 16) + "<br/>");

document.writeln("8 = " + 8 + "<br/>");

</script>
</body>
</html>


It seems if you are silly, then your webbrowser will just assume you don't know what you are doing and use decimals.

alpha_foobar
Junior Poster
182 posts since May 2005
Reputation Points: 20
Solved Threads: 5
 

If you're using parseInt to obtain 08 or 09's, You just have to set the redix (the numeral system) as 10 to get numbers in decimal system. Like this: parseInt(08,10). Bye!

gbenjamin
Newbie Poster
1 post since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You