Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C
void main()
{
 long n,dec,mult,r,base;
 clrscr();
 printf("\n Enter a base : ");
 scanf("%ld",&base);
 printf("\n Enter a number :");
 scanf("%ld",&n);
 dec = 0;
 mult=1;
 printf("\n Decimal equivalent of base %ld number %ld is ",base,n);
 while ( n != 0 )
 {
  r = n % 10;
  n /= 10;
  r = r * mult;
  dec = dec + r;
  mult *= base;
 } 
 printf("%ld",dec);}
this program converts the integer part of any number system of base 2, 8 &16 to decimal. please tell me wht command shld b given 2 calculate the fractional part also. i need it urgently plz help.
Posted 20-Sep-12 7:03am
BeenaM308
Edited 20-Sep-12 7:04am
v2
Comments
ridoy at 20-Sep-12 13:07pm
   
clear the question more..

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Each digit to the right of the decimal point is the reciprocal of the power of the base for that base. So for octal numbers the value 0.44 equates to
0
4 / 8  // .4
4 /64  // . 04
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,745
1 OriginalGriff 6,696
2 CPallini 5,315
3 George Jonsson 3,599
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100