P: n/a

I am trying to apply bitwise operations on float, double, and long
double values. I do not believe this is possible natively, so I
created a wrapper class to construct a double value given two
integers, similar to the bit representation of floating point numbers.
However, this is tedious and the decoding/encoding process is not
efficient.
Is there a portable way to apply AND, OR, XOR, >>, and << to doubles?
Thanks in advance.  
Share this Question
P: n/a

<si******@gmail.comwrote:
>I am trying to apply bitwise operations on float, double, and long
double values. I do not believe this is possible natively, so I
created a wrapper class to construct a double value given two
integers, similar to the bit representation of floating point numbers.
However, this is tedious and the decoding/encoding process is not
efficient.
Is there a portable way to apply AND, OR, XOR, >>, and << to doubles?
Note that your first and second paragraph do not agree, the second on talks
only of doubles. There is an IEEE spec on doubles (and, I think, float)
which is reputedly used quite a bit. If you consider that as "portable" you
could restrict yourself to that and maybe get away with calling it portable.
I can't for the life of me imagine why anyone would want to do this. But I
refuse to ask you, it is none of my business and has no bearing on the
answer to the question.  
P: n/a

On May 17, 5:53 pm, "osmium" <r124c4u...@comcast.netwrote:
<siryu...@gmail.comwrote:
I am trying to apply bitwise operations on float, double, and long
double values. I do not believe this is possible natively, so I
created a wrapper class to construct a double value given two
integers, similar to the bit representation of floating point numbers.
However, this is tedious and the decoding/encoding process is not
efficient.
Is there a portable way to apply AND, OR, XOR, >>, and << to doubles?
Note that your first and second paragraph do not agree, the second on talks
only of doubles. There is an IEEE spec on doubles (and, I think, float)
which is reputedly used quite a bit. If you consider that as "portable" you
could restrict yourself to that and maybe get away with calling it portable.
I can't for the life of me imagine why anyone would want to do this. ButI
refuse to ask you, it is none of my business and has no bearing on the
answer to the question.
Well, it does, sort of. Because until we know what the
semantics of the operations are supposed to be, it's hard to say
how to best achieve them. What should the result of 1.33 
3.1419 be? I can't think of anything reasonable.

James Kanze (Gabi Software) email: ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.Cyrl'École, France, +33 (0)1 30 23 00 34  
P: n/a

On 17 Maj, 17:34, siryu...@gmail.com wrote:
I am trying to apply bitwise operations on float, double, and long
double values. I do not believe this is possible natively, so I
created a wrapper class to construct a double value given two
integers, similar to the bit representation of floating point numbers.
However, this is tedious and the decoding/encoding process is not
efficient.
Is there a portable way to apply AND, OR, XOR, >>, and << to doubles?
Thanks in advance.
No. Even if you can assume e.g. a IEEE float/double, using bitmagic
will not be portable as the representation might differ (similarly to
how unsigned ints have different endianness on different compters).
/Peter  
P: n/a

On May 17, 4:34 pm, siryu...@gmail.com wrote:
I am trying to apply bitwise operations on float, double, and long
double values. I do not believe this is possible natively, so I
created a wrapper class to construct a double value given two
integers, similar to the bit representation of floating point numbers.
However, this is tedious and the decoding/encoding process is not
efficient.
Is there a portable way to apply AND, OR, XOR, >>, and << to doubles?
Thanks in advance.
I am not sure about the meaning of ANDm OR and XOR for doubles, but <<
can be interpreted as multiplication by 2.0 , similarly >2 can be
interpreted as multiplication by 0.5. This was the opertations are
consistent with the operatrion for integers.   This discussion thread is closed Replies have been disabled for this discussion.   Question stats  viewed: 5607
 replies: 4
 date asked: May 17 '07
