Add to Favorites    Make Home Page 1962 Online  
 Language Categories  
 Our Services  

Home » C Home » Mathematics Home » IEEE 754 representation of any floating point number

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title IEEE 754 representation of any floating point number
Author Dinesh Reddy Jeeru
Author Email dinesh_192000 [at] yahoo.com
Description
Category C » Mathematics
Hits 385086
Code Select and Copy the Code
#include<stdio.h> int power(int,int); void main() { float a,f,r,x,temp,sum,g; int n,i,j,u,o,b[30],c[30],B[30],Z[30],e[10],m[25],F[40],t,k,y,z,count,exp,h,d; clrscr(); printf("enter the number "); scanf("%f",&a); g=a; if(a<0) { a=0-a; n=a; } else n=a; f=a-n; /* conversion of integer part to binary */ i=0; while(n!=0) { b[i]=n%2; n=n/2; i++; } /* arranging the bits of the binary equalent of integer part*/ for(j=i-1,k=0;j>=0;j--,k++) c[k]=b[j]; if(k==0) { c[k]=0; k=k+1; } /* conversion of floating part to binary */ sum=0; for(i=1;i<=11;i++) { t=power(2,i); r=t; x=1/r; sum=sum+x; temp=sum; if(temp <= f) { B[i-1]=1; sum=temp; } else { B[i-1]=0; sum=temp-x; } } /* arranging the bits of the binary equalent of floating part*/ for(i=0,z=k;i<=10;i++,z++) c[z]=B[i]; /* Combined representation */ //printf(" the equavalent binary representation of the floating point number is: "); //for(y=0;y<=z-1;y++) // { // printf("%d",c[y]); // if(y==k-1) // printf("."); // } /* IEEE 754 format representation */ count=k-1; printf("The IEEE 754 standard floating point number allignment is "); exp=127+count; i=0; while(exp!=0) { Z[i]=exp%2; exp=exp/2; i++; } if(count==0) { Z[i]=0; i++; } if(g<0) printf(" The sign value is %d",1); else printf(" The sign value is %d",0); /* Arranging the bits in order for exponent*/ for(j=i-1,k=0;j>=0;j--,k++) e[k]=Z[j]; printf(" The value of exponent is : "); for(u=0;u<=k-1;u++) printf("%d",e[u]); /* Arranging the bits in order for Mantissa*/ printf(" The value of mantissa is :"); d=z-1; for(y=1,o=0;o<=22;y++,o++) { if(o<d) m[o]=c[y]; else m[o]=0; printf("%d",m[o]); } printf(" The FINAL REPRESENTATION IS : "); for(h=0;h<=31;h++) { if(h==0) { if(g<0) F[0]=1; else F[0]=0; } if(h<=k && h!=0) F[h]=e[h-1]; else if(h>k && h!=0) F[h]=m[h-9]; printf("%d",F[h]); } getch(); } int power(int w, int d) { int pro,i; pro=1; for(i=1;i<=d;i++) pro=pro*w; return(pro); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi �դ ?�� ��??���
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=956


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review