[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: converting numbers



> Where's the FM that tells how to convert numbers, like 0x11A to a 
> "decimal"?
You'll find it in any C manual, or try "man strtol" for the strtol() function.

If all you want is to convert to decimal, use this short C-program:
#include <stdio.h>

void main(int argc, char **argv)
{
    while (*++argv) printf("%s == %i\n", *argv, strtol(*argv));
}

It simply prints all arguments as decimal numbers.  To use it, save it as
decimal.c  Then run "gcc -O2 decimal.c" and "mv a.out decimal"
Possibly also "chmod oug+rx decimal"

You can now use commands like "./decimal  25 0xFF 011" and get
25 == 25
0xFF == 255
011 == 9

The first one was an ordinary number, the other hexadecimal and the third one 
octal.

Helge Hafting


Reply to: