unix script for converting a decimal to binary | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

unix script for converting a decimal to binary

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-19-2005
softy softy is offline
Registered User
 
Join Date: Sep 2005
Last Activity: 19 October 2005, 9:27 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
unix script for converting a decimal to binary

Could anybody please help me in writing a script in unix for converting a decimal number to binary number.
Sponsored Links
    #2  
Old 10-19-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 24 Times in 23 Posts
Is this homework??

man bc

Cheers
ZB
Sponsored Links
    #3  
Old 10-19-2005
softy softy is offline
Registered User
 
Join Date: Sep 2005
Last Activity: 19 October 2005, 9:27 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
I tried 'bc' and 'dc'... but I am not convenient with them.. can you provide the solution...
    #4  
Old 10-19-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 24 Times in 23 Posts
Hmm... benefit of the doubt then....

echo "ibase=10;obase=2;128" | bc

Where 128 is the number you want to convert.

I'll leave it to you to convert this into a versatile script.

Cheers
ZB
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Decimal to BCD (Binary Coded Decimal) caramba Homework & Coursework Questions 2 12-07-2010 12:10 AM
Decimal to BCD (Binary Coded Decimal) caramba UNIX for Dummies Questions & Answers 1 10-19-2010 03:59 AM
converting decimal in other systems with bc wiseguy Shell Programming and Scripting 2 01-29-2009 11:57 AM
Converting Binary decimal coded values to Ascii Values gaur.deepti UNIX for Advanced & Expert Users 3 04-02-2008 12:33 PM
Converting a decimal into integer idro Shell Programming and Scripting 4 10-31-2007 01:51 PM



All times are GMT -4. The time now is 02:40 PM.