unix script for converting a decimal to binary


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unix script for converting a decimal to binary
# 1  
Old 10-19-2005
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.
# 2  
Old 10-19-2005
Is this homework??

man bc

Cheers
ZB
# 3  
Old 10-19-2005
I tried 'bc' and 'dc'... but I am not convenient with them.. can you provide the solution...
# 4  
Old 10-19-2005
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Negative decimal to binary

Is there a fast way to convert a negative decimal value into a signed binary number in bash script ? I've looked a lot on internet but I saw nothing... (For exemple : -1 become 11111111.) (9 Replies)
Discussion started by: Zedki
9 Replies

2. Programming

Binary to decimal for particular bits

Hello, I have script which work fine on particular data.file . The next feature I want to achieve is to get the decimal equivalent of data to data. The data looks like this : data(01000000000000000000110000000000) thank you.. #include <iostream> #include <fstream> #include... (4 Replies)
Discussion started by: emily
4 Replies

3. Shell Programming and Scripting

How to get the negate of decimal to binary?

Hi All, New to this forum (and yes , a newbie in programming..:p) I have a decimal to binary converter script done this way : i=$1 bit0=$(( (i & 0x01) > 0 )) bit1=$(( (i & 0x02) > 0 )) bit2=$(( (i & 0x04) > 0 )) bit3=$(( (i & 0x08) > 0 )) bit4=$((... (6 Replies)
Discussion started by: digiteltlc
6 Replies

4. Shell Programming and Scripting

Converting decimal to hex

How to convert decimal value to hex and than take 1st digits as variable sample data 84844294,5,6 51291736,2,3 84844294,5,6 51291736,2,3 i can use {printf "%x,%d\n",$1,$2} but than i want to filter base on 1st hex digit 1st recrd (1 Reply)
Discussion started by: before4
1 Replies

5. Homework & Coursework Questions

Decimal to BCD (Binary Coded Decimal)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Design an algorithm that accepts an input a decimal number and converts it into BCD (Binary... (2 Replies)
Discussion started by: caramba
2 Replies

6. UNIX for Dummies Questions & Answers

Decimal to BCD (Binary Coded Decimal)

Anybody please help me... Design an algorithm that accepts an input a decimal number and converts it into BCD (Binary Coded Decimal) representation. Also, draw its Flow Chart. This is a unix qn... plz post algorithm for that :confused: (1 Reply)
Discussion started by: caramba
1 Replies

7. Shell Programming and Scripting

Converting decimal to integer

The shell mentioned below will show a warning if the page takes more than 6 seconds to load. The problem is that myduration variable is not an integer. How do I convert it to integer? myduration=$(curl http://192.168.50.1/mantisbt/view.php?id=1 -w %{time_total}) > /dev/null ; ] && echo... (3 Replies)
Discussion started by: shantanuo
3 Replies

8. Shell Programming and Scripting

converting decimal in other systems with bc

Hallo, how can I convert number systems with bc? I need to convert a decimal number to octal, dual or hex number... (2 Replies)
Discussion started by: wiseguy
2 Replies

9. UNIX for Advanced & Expert Users

Converting Binary decimal coded values to Ascii Values

Hi All, Is there any command which can convert binary decimal coded values to ascii values... i have bcd values like below оооооооооооо0о-- -v - Pls suggest a way to convert this. Thanks, Deepti.Gaur (3 Replies)
Discussion started by: gaur.deepti
3 Replies

10. Shell Programming and Scripting

Converting a decimal into integer

Hi all, I'm trying to convert a decimal number into an integer number; I'm doing this: n=`echo |awk '{ print "'"$mem"'"*10}'` where the variable mem is equal to 3.7 I'd like to obtain 37, but the expression above gives me 30. Help please!!!! thx a lot (4 Replies)
Discussion started by: idro
4 Replies
Login or Register to Ask a Question