Follow-up Comment #22, sr #111312 (group freeipmi):

So I'm super perplexed.  On your system:

```
ipmi-sensor-decode: raw value = F9
ipmi-sensor-decode: dval initial = 249.000000
```

and mine

```
ipmi-sensor-decode: raw value = F9
ipmi-sensor-decode: dval initial = -7.000000
```
```

all I am doing is casting an "uint8_t" to a "char" and then setting a double.

```
dval = (double)((char) raw_data);

```

And that is the output from 'dval initial' above.  

The unsigned value of 0xF9 is 249 and the signed value is -7.  So the question
is, why in the world on your system does the casting of 249 to -7 set the
value of dval to 249.

Assuming no memory corruption (we could add an extra fprintf just to be extra
sure), I don't know why this would happen on your system.  I don't know if
this is some oddity of arm or your compiler or something.

Does this code snippet compiled under your compiler do what I would hope it
does?

```
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int
main ()
{
  uint8_t a = 0xF9;
  double b = (char) a;
  printf ("%f\n", b);
}

```

On my system, this outputs -7.



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/support/?111312>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to