Page 1 of 1
Floating point diveded by 2
Posted: Thu Jun 09, 2011 10:05 am
by Jan Lichtenbelt
Is it possible to divide a floating point variable A by 2 in the following way?
A>>1
Or must it be done by a floating point division
Kind regards
Jan Lichtenbelt
Re: Floating point diveded by 2
Posted: Thu Jun 09, 2011 10:58 am
by Benj
Hi Jan,
I'm not too sure about this one. I have a feeling it won't work but why not give it a go on the hardware and let us know your results. It certainly won't hurt anything.
Re: Floating point diveded by 2
Posted: Thu Jun 09, 2011 3:24 pm
by Jan Lichtenbelt
OK, You are right. I could check it myself. Here are the results
A is a floating point variable, in my example 4.321
respectively: A>>1 , A/2 , fdiv(A,2)
Simulation: 2.000000 2.160500 2.160500
PIC-Hardware: 0.000000 0.000000 2.160500
So the only correct way is using the fdiv() function
regards
Jan
Re: Floating point diveded by 2
Posted: Thu Jun 09, 2011 5:55 pm
by Benj
Hi Jan,
Thanks for letting us know. I had a feeling it wouldn't be that simple but glad you tested it to be sure.