i disagree. assming i know the format that my floats are in, i have every means at hand to make the values exactly what i want them to be.
You can disagree all you like. It doesn't make you right. Floating point numbers are inprecise. Therefore, unless you have memorized every single point at which it decides to round, the best you'll get is "close", which is what floating point numbers are. They're "close". They're not accurate.
"how do i put rvalue bits inside of a variable
for which bit modification is not allowed by C without creating a temporary variable?"
Well I guess you just answered your own question, didn't you?
Oh, and the whole "rvalue" issue doesn't exist as far as your not being able to modify it and as to your passing it to a function. When you pass anything to a function, it's automaticly assigned to an lvalue in the call. To use your example:
Code:
5.5f = somefunc( ); /* 5.5f is an "rvalue", because it's not a variable, it's a numeric constant */
somefunc( 5.5f ); /* 5.5f is automaticly a "lvalue" when it reaches the function */
Anything you pass to this function will automaticly be in an "lvalue" when it gets there. It's impossible to have an "rvalue" reach a function call. Furthermore, were this not a floating point number, you could automaticly mung its bits in the assignment:
Code:
somefunc( 5 << 3 );
So, as stated, to do the same thing to a float, you cast it to an integer first. You can play with void pointers or whatever you like, but the end result is some value ending up stuck in a variable when it reaches the function. It'll get there in a variable. Don't believe me?
Code:
#include<stdio.h>
void foo( float f )
{
f = 1.0;
printf("f is %f\n", f );
}
int main( void )
{
foo( 10.10 );
return 0;
}
There's no such thing as an "rvalue" reaching a function. Ever. It's not going to happen.
So really, to simply clarify the issue, you could have just asked:
"Is there any way for me to shift a numeric floating point constants' bits without using a variable or a cast?"
See how clear that is? Now, a union is going to use a variable. You don't want that. Now you don't want a cast either. Therefore your answer is: no.
[edit]
for those of you who are still looking for things to ridicule me on.
For those of you still looking for a reason to whine, you were the one who turned this into a flame war. Dave simply stated that what you want to do isn't defined by the standard. Then you got your britches in a bunch about it for some reason.
[edit]
Quzah.