Re: integer to float




Markus wrote:
> Hello,
>
> I am new in C programming. I currently start to work with an TI dsp
> (C6713). My question is whats happen when I cast an 32Bit integer value
> into an 32bit float value.

The binary representation of the integer changes. Depending on
the numerical value of the integer, some round-off error could
be introduced,

To see the binary representations, try something like

long int i;
float j;

i = 27;
j = (float) i;

printf("Integer bit pattern: %x\n",&i);
printf("Float bit pattern: %x\n\n",&j);
printf("Numerical value of float: %4.12g");

Rune

.



Relevant Pages

  • Re: What is a "floating-point integer representation"?
    ... Basically, every float has a binary representation, and every binary representation can be expressed as a base-10 integer. ... The reason for representing a float as an integer is that you can write it to a text file without loosing any significance. ... make sure that the machines respect the same storage when reading/writing the data between different machines.) ... % trimmed float ...
    (comp.soft-sys.matlab)
  • Re: Binary Decimals in Python
    ... Is this by design? ... The int() constructor returns integers. ... look to float() for non-integral values. ... Binary representation isn't supported yet, ...
    (comp.lang.python)
  • Re: Wav File
    ... I need to convert the PCM values to float ... My question was that you can't apply a dsp operation using the PCM values. ...
    (comp.dsp)
  • Re: What is a "floating-point integer representation"?
    ... Basically, every float has a binary representation, and every binary representation can be expressed as a base-10 integer. ... The reason for representing a float as an integer is that you can write it to a text file without loosing any significance. ... However, in the help of the hex2dec function itself is IMO no reference to the float part necessary, since we only operate with a string and an integer. ...
    (comp.soft-sys.matlab)
  • Re: how the following code works?
    ... oops, you had taken liberty over the size of float! ... the above code gives the binary representation of a. ...
    (comp.lang.c)