Float My Boat
Posted on Tue 21 June 2005 by alex in general
Today has been a struggle to beat the compiler into submission for so I could transfer floating point numbers out of a signal hardware context into something that printf() would sanely display. Simple assignment fails as the compiler thinks you passing an integer and munges the result. In the end I just abused the casting of pointers to prevent conversion:
/* ** These #define's allow you to pick out floating point registers by ** clever casting. Otherwise the C compiler will do subtle and broken ** things to the value you actually want. */ #define get_sf_reg(x) *( (float *) &x) #define get_df_reg(x) *( (double *) &x) #define get_qf_reg(x) *( (long double *) &x)
It doesn't help that the office has been running at around 28 degrees all day. Heat + thinking are not very good bed fellows. Especially considering I'm not that familiar with Floating Point maths (all the 3D stuff I worked on in my ST days was integer based stuff). Still none of this matters now because tomorrow I go to Glasto!.
Although there looks like there may be some rain I don't think its going to be anything like last year. We also have the benefit of the camper van this year, chosen mainly for the in built shower :-)
No updates for the next week, well maybe not many!