Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

unix script for converting a decimal to binary

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 10-19-2005
zazzybob's Unix or Linux Image
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 25 Times in 23 Posts
Is this homework??

man bc

Cheers
ZB
Sponsored Links
    #3  
Old Unix and Linux 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 Unix and Linux 10-19-2005
zazzybob's Unix or Linux Image
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 25 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 06:33 AM.