??? 08/26/08 12:17 Read: times |
#157770 - Nothing wild Responding to: ???'s previous message |
Nothing wild about the type cast.
Using an union doesn't buy you any extra security when converting from four raw bytes to a float. Both alternatives will produce the wrong result if the two alternatives have different size or the raw data does not represent a floating-point value of the correct binary format. The only advantage with a union is that a big assign can't be made to a too small variable. |
Topic | Author | Date |
silly C question | 01/01/70 00:00 | |
*(float*)&time | 01/01/70 00:00 | |
Thanks!!! | 01/01/70 00:00 | |
Here's one without wild casting: | 01/01/70 00:00 | |
Nothing wild | 01/01/70 00:00 | |
union misuse | 01/01/70 00:00 | |
Not hiding cast | 01/01/70 00:00 | |
Programmer knowledge required. | 01/01/70 00:00 | |
Hiding of portability issue | 01/01/70 00:00 | |
Portability C | 01/01/70 00:00 |