Convert a Decimal Number into IEEE 754 format [no code please]

Sep 4, 2012 at 2:05pm
Hi,
I am trying to code a C++/C program that can convert a decimal integer or floating point number int IEEE 754 equivalent of any binary representation of numbers. I am able to do the following:
>Convert an integer into IEEE 754 whether its -ve or not.

I need a convenient logic that will convert an floating point number to equivalent binary as an array. Please do not post the code. Just suggest appropriate algorithm.

Thanks
Sep 4, 2012 at 4:35pm
You could use the compiler's casting functions. Or are you wanting to do this manually bit-wise?
Sep 5, 2012 at 1:24pm
I want to do it manually. From the scratch.
Sep 5, 2012 at 3:18pm
closed account (o1vk4iN6)
Well its such a trivia thing to do i wouldnt call it an algorithm.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct {
int sign : 1;
int exponent : 8;
int fraction : 23;
}
int input;
if negative
   Sign = 1
   input = -input
else
   sign = 0

get decimal place and make exponent equal it

fraction = input

Topic archived. No new replies allowed.