blob: b8bb4a94ec9fd69fc193d9f904db64afc0f4bcf9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
--- mcop/buffer.cc.orig 2004-03-24 14:51:23.586055192 +0100
+++ mcop/buffer.cc 2004-03-24 14:56:14.054897216 +0100
@@ -87,9 +87,8 @@
void Buffer::writeFloat(float f) {
// FIXME: on some machines this may fail badly (there is explicit
// float marshalling and demarshalling code in mico/orb/util.cc)
-
- long *f_as_long = (long *)&f;
- writeLong(*f_as_long);
+ union { float f; long l; } u = {f};
+ writeLong(u.l);
}
void Buffer::writeFloatSeq(const std::vector<float>& seq) {
@@ -252,9 +251,10 @@
float Buffer::readFloat()
{
// FIXME: see writeFloat()
- long f_as_long = readLong();
+ union {float f; long l; } u;
+ u.l = readLong();
- if(!_readError) return *(float *)&f_as_long;
+ if(!_readError) return u.f;
return 0.0;
}
|