473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Why 08, 09 cannot be used as 8 ,9?

If you do $((08+1)) or $((09+1)) in terminal, linux shows an error.
However, you can use 07,06,05,04,03,02,01,00, and Linux treat them as 7,6,5,4,3,2,1,0.

Can someone tell me how to make 08 and 09 work in this way?
Feb 20 '07 #1
6 4343
Motoma
3,237 Expert 2GB
If you do $((08+1)) or $((09+1)) in terminal, linux shows an error.
However, you can use 07,06,05,04,03,02,01,00, and Linux treat them as 7,6,5,4,3,2,1,0.

Can someone tell me how to make 08 and 09 work in this way?
That's easy!
Prefacing a number with a 0 when it isn't the only digit before a decimal (.) will cause most programming languages to treat is as Octal (base 8). The highest numeric digit in octal is 7, thus 8 and 9 will not show up.

If you don't believe me, try 077 and see what you get.
Feb 21 '07 #2
can someone tell me how to make 08 and 09 work as 8, 9?
Feb 21 '07 #3
Motoma
3,237 Expert 2GB
can someone tell me how to make 08 and 09 work as 8, 9?
As far as I know, this cannot be done in the way you've posed the question. This is similar to asking for 0x11 be represented as 11 (which is certainly not the case).
Feb 21 '07 #4
if you need them to be viewed as 08 and 09 you can do your calculations with the decimal equivalents 0 - 9 and use printf to display them with the leading 0 (zero)
Apr 27 '07 #5
michaelb
534 Expert 512MB
This behavior seems to vary depending on the shell:
Expand|Select|Wrap|Line Numbers
  1. ~> echo $SHELL
  2. /usr/local/bin/bash
  3. ~> echo $((09+7))
  4. -bash: 09: value too great for base (error token is "09")
  5. ~> ksh
  6. $  echo $((09+7))
  7. 16
  8. $
  9.  
There's also the typeset built-in which can be used for formatting:
Expand|Select|Wrap|Line Numbers
  1. $ typeset -Z2 num1=9  
  2. $ typeset -Z3 num2   
  3. $ num2=8
  4. $ echo $num1
  5. 09
  6. $ echo $num2
  7. 008
  8. $ echo $((num1 * num2))
  9. 72
  10.  
Apr 27 '07 #6
This worked for me in the bash shell. If I tried to default the dirNUM to 3 digits first then I would error out with the 08 errors.
Expand|Select|Wrap|Line Numbers
  1.       dirNUM=1
  2.       until [[ $dirNUM == 367 ]]
  3.       do
  4.          # Change directory number to 3 digits
  5.          if [[ ! -d ${root_dir}/$(printf "%.3d" $dirNUM) ]]
  6.          then
  7.             mkdir ${root_dir}/$(printf "%.3d" $dirNUM)
  8.          fi
  9.          ((dirNUM+=1))
  10.       done
Dec 21 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Ryan Park | last post by:
Hi, //SITUATION I got a panel control that hold a certain position on a form. Every controls or UIs are on this panel. At certain situation, I called dispose() method of this panel control...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
12
by: ~~~ .NET Ed ~~~ | last post by:
Hi, I have a standalone XML file (with the appropriate xml document header) that works fine when I load it using XmlDocument. I can have child elements like this without problems: ...
4
by: Alfetta159 | last post by:
I've been setting up a schema with the XML Designer in VS .NET 2003. The designer lets me set up a lot of things including a complex type that contains an unnamed complex type called modified. ...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
0
by: Jean-Marc Blaise | last post by:
Dear all, I would like to signal an inconvenience with the db2imigr, if root's environment points to a DB2 instance (Aix). We did a /usr/opt/db2_08_01/db2ckmig .... worked ok saying db(s) can...
4
by: eelis.net | last post by:
Hi I tried to convert the following C# code to vb.net. code in C# ________________________________________________________________ using System; using System.Reflection; using...
2
by: mudge | last post by:
Hi, I'm getting some very strange problems with some C# code. We're running an ASP.NET application on a local server in a DMZ. If I access it using the internal address, the application works...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello, mister I have an application web asp.net 2.0 + vs 2005 and VS 2005 Web Application Project. Its appears this error in execution: "Cannot Create/Shadow Copy '<projectname>' when that...
2
by: SCPOS | last post by:
Cannot delete X: It is being used by another person or program. Close any programs that might be using the file and try again. Of course I have tried closing any programs I know of that may be...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.