Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 15th, 2007, 1:41 AM   #1
Silicon_Pudding
Newbie
 
Silicon_Pudding's Avatar
 
Join Date: Jun 2006
Location: In a box
Posts: 27
Rep Power: 0 Silicon_Pudding is on a distinguished road
Help with this code

ITERATE=240
for COUNT in `seq -w 1 $TOTAL`
do
  OTHER=$(($COUNT*2))
  ... more stuff
  ...
done
The problem I am having is that I can't figure out how to multiply COUNT by 2. In this example since TOTAL is 240, COUNT will be 3 digits. I get an error message at count 8 saying the value is too great for the base, which I assume is because of 3 digits and something with binary.

Is there a way I can multiply this number by two, while still interating through by one?
__________________
~ Silicon Enhanced Pudding
"It's magically delicious"
Silicon_Pudding is offline   Reply With Quote
Old Mar 15th, 2007, 3:55 PM   #2
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
Don't use the -w option on seq. Many things interpret numbers starting with 0 as octal (base 8), likewise with 0x and hexadecimal (base 16).
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Mar 15th, 2007, 4:45 PM   #3
Silicon_Pudding
Newbie
 
Silicon_Pudding's Avatar
 
Join Date: Jun 2006
Location: In a box
Posts: 27
Rep Power: 0 Silicon_Pudding is on a distinguished road
I need the -w option to keep the 000 spaces in front of the number. Is there another clean way to do this?
__________________
~ Silicon Enhanced Pudding
"It's magically delicious"
Silicon_Pudding is offline   Reply With Quote
Old Mar 17th, 2007, 12:20 PM   #4
Serinth
Programmer
 
Serinth's Avatar
 
Join Date: Sep 2005
Posts: 50
Rep Power: 3 Serinth is on a distinguished road
try this:
previously declare variable OTHER and set it to 0 then in the loop:
let OTHER="$COUNT"*2
__________________
A girl talked to me once.

http://www.latestanime.com
Serinth is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
EXECryptor software protection Jean5 C++ 35 Oct 10th, 2006 7:10 PM
Little help whoawhoayoyo Assembly 8 Apr 18th, 2006 7:10 PM
How to post a question nnxion C++ 10 Jun 3rd, 2005 11:53 AM
How to post a question nnxion C++ 0 Jun 3rd, 2005 8:55 AM
How to post a question nnxion C 0 Jun 3rd, 2005 8:55 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:29 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC