Sponsored Content
Homework and Emergencies Homework & Coursework Questions Problem with simple octal to decimal code Post 302511730 by qf_woodfox on Thursday 7th of April 2011 12:04:19 PM
Old 04-07-2011
Quote:
Originally Posted by Perderabo
Code:
    ( digit4 = number/1000 );
    ( digit3 = number/100 - digit4*1000 );

That does not compute. Try the computation yourself with, say, number=1234.
Wow, I can't believe I didn't pick that upSmilie. Thanks a lot
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[bash]printf octal instead of decimal

Hello everybody, I would like to understand why the printf function is returning me an octal value with this command : printf %4.4d 0010 returns 0008 printf %4.4d 10 returns 0010 Thanks for help. (3 Replies)
Discussion started by: dolphin06
3 Replies

2. 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

3. 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

4. Shell Programming and Scripting

Unknown (probably) simple problem with my code

I'm relatively new to both UNIX and Linux and slightly less new at programming. But I can't figure out why this won't run properly. It's meant to calculate the GCD of two numbers (simple enough, you'd think). And I designed it myself and it looks good to me and my instructor won't respond. If... (1 Reply)
Discussion started by: Sevchenko
1 Replies

5. Shell Programming and Scripting

How to convert a file containing hex code to decimal using script?

The file contains code like the below and need to convert each one into a decimal 00 00 00 04 17 03 06 01 So the output should come as 0 0 0 4 23 3 6 1 (24 Replies)
Discussion started by: necro98
24 Replies

6. Shell Programming and Scripting

Decimal number calculation problem

I have a below snippet of code from my perl script and its causing a problem when the output of $lTAX is 0 (zero) its getting displayed as -0.00. I want output to be 0 not -0.00. Any help would be appreciated. #!/usr/bin/perl my $lTotA = 50.94; my $lVatA = 8.49; my $lAllocD; my $lAdjNr =... (4 Replies)
Discussion started by: Devesh5683
4 Replies

7. Shell Programming and Scripting

Facing problem while printing accurate decimal value

Hi, I have a file tp.txt having below data CE2DD,N,5055,16.12.2013,3.114,12195.89,MVR,003388,Web::00000005055,Web Payment and i am using below code to print the values for var_amt_pay in `awk -F',' '{ arr += $6} END {for (i in arr) {print i "," arr } }' tp.txt` do ... (2 Replies)
Discussion started by: ranabhavish
2 Replies

8. Programming

Urgent help needed.. C++ program to convert decimal to hexa decimal

Hi , seq can be 0...128 int windex = seq / 8; int bindex = seq % 8; unsigned char bitvalue = '\x01' << (7-bindex) ; bpv.bitmapvalue = bitvalue; This is the part of a program to convert decimal to bitmap value of hexadecimal. I want this to change to convert only to... (1 Reply)
Discussion started by: greenworld123
1 Replies

9. Shell Programming and Scripting

Problem with gstat and octal value

Here are a few lines from my script. The problem I am having is that the statement for gstat returns this error: line 43: The statement is coming from gstat. Is there a way to fix it? Apparently -eq 02 is coming up as some octal value, I need it to be recognized as 02. Apparently in... (4 Replies)
Discussion started by: newbie2010
4 Replies
od(1)							      General Commands Manual							     od(1)

Name
       od - create file octal dump

Syntax
       od [options] [file] [offset] [label]

Description
       The  command displays file, or its standard input, in one or more dump formats as selected by the first argument.  If the first argument is
       missing, -o is the default.  Dumping continues until end-of-file.

Options
       -a[p|P] Interprets bytes as characters and display them with their ACSII names.	If the p character is given also,  then  bytes	with  even
	       parity are underlined.  The P character causes bytes with odd parity to be underlined.  Otherwise the parity bit is ignored.

       -b      Displays bytes as unsigned octal.

       -c      Displays  bytes	as ASCII characters.  Certain non-graphic characters appear as C escapes: null=, backspace=, formfeed=f, new-
	       line=
, return=
, tab=	; others appear as 3-digit octal numbers.  Bytes with the parity bit set are displayed in octal.

       -d      Displays short words as unsigned decimal.

       -f      Displays long words as floating point.

       -h      Displays short words as unsigned hexadecimal.

       -i      Displays short words as signed decimal.

       -l      Displays long words as signed decimal.

       -o      Displays short words as unsigned octal.

       -s[n]   Looks for strings of ASCII characters of n minimum length.  By default, the minimum length is 3 characters.

       -v      Displays all data and indicates lines identical to the last line shown with an * in column 1.

       -w[n]   Specifies the number of input bytes to be interpreted and displayed on each output line. If w is not specified, 16 bytes  are  read
	       for each display line.  If n is not specified, it defaults to 32.

       -x      Displays short words as hexadecimal.

       An upper case format character implies the long or double precision form of the object.

       The  offset  argument  specifies  the  byte  offset into the file where dumping is to commence.	By default this argument is interpreted in
       octal.  A different radix can be specified; If ``.'' is appended to the argument, then offset is interpreted in decimal.  If offset  begins
       with  ``x'' or ``0x'', it is interpreted in hexadecimal.  If ``b'' (``B'') is appended, the offset is interpreted as a block count, where a
       block is 512 (1024) bytes.  If the file argument is omitted, an offset argument must be preceded by ``+''.

       The radix of the displayed address is the same as the radix of the offset, if specified; otherwise it is octal.

       The label is interpreted as a pseudo-address for the first byte displayed.  It is shown	in  ``()''  following  the  file  offset.   It	is
       intended to be used with core images to indicate the real memory address.  The syntax for label is identical to that for offset.

Restrictions
       A file name argument can't start with ``+''.  A hexadecimal offset can't be a block count.  Only one file name argument can be given.

       It is an historical botch to require specification of object, radix, and sign representation in a single character argument.

See Also
       adb(1) - VAX only, dbx(1)

																	     od(1)
All times are GMT -4. The time now is 05:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy