CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Sign Bit in a float

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nilsener
Guest







Sign Bit in a float
PostPosted: Wed Dec 11, 2002 4:22 am     Reply with quote

Dear,

where to find the sign bit in a float variable ?

Thanks for helping

regards nilsener
___________________________
This message was ported from CCS's old forum
Original Post ID: 9965
R.J.Hamlett
Guest







Re: Sign Bit in a float
PostPosted: Wed Dec 11, 2002 5:38 am     Reply with quote

:=Dear,
:=
:=where to find the sign bit in a float variable ?
:=
:=Thanks for helping
:=
:=regards nilsener
It is the top bit of the third byte. Basically the low three bytes contain an integer, with the fourth byte containing the binary exponent. The integer is 23bits, plus the sign bit.
So:
union {
int8 b[4];
float f;
} value;

value.f=10000.0;

if (value.b[2] & 128) {
//This will test as true if the float is negative

}

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 9968
nilsener
Guest







Re: Sign Bit in a float
PostPosted: Wed Dec 11, 2002 9:56 am     Reply with quote

Thanks :)

:=:=Dear,
:=:=
:=:=where to find the sign bit in a float variable ?
:=:=
:=:=Thanks for helping
:=:=
:=:=regards nilsener
:=It is the top bit of the third byte. Basically the low three bytes contain an integer, with the fourth byte containing the binary exponent. The integer is 23bits, plus the sign bit.
:=So:
:=union {
:= int8 b[4];
:= float f;
:=} value;
:=
:=value.f=10000.0;
:=
:=if (value.b[2] & 128) {
:= //This will test as true if the float is negative
:=
:=}
:=
:=Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 9976
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group