??? 08/27/08 10:11 Read: times |
#157788 - Hiding of portability issue Responding to: ???'s previous message |
I wasn't discussing any portability issues. Some form of non-portable assumption is needed to transfer a floating-point value over the serial channel and then make the receiver use it, unless it is transmitted in ASCII format and recovered with sscanf() or similar, with the resulting loss of precision from two potentially lossy conversions.
What I was discussing was that the union method hides the cast, making non-portable code look more portable than it is. Without seeing the definition of the union, you are unable to know that a type cast is hidden in the code. Note your original post, titled "Here's one without wild casting". The title seems to imply that you dislike casts, but hiding the conversion in a union does not add or remove anything wild. It just hides the fact that a non-portable step is performed. Abstraction is good, when you hide the inner workings of a class or an algorithm. Hiding assumptions or compatibility issues is not so good. |
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 |