0

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
:?:

4
Contributors
3
Replies
4
Views
11 Years
Discussion Span
Last Post by gbenjamin
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?

0

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.

0

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!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.