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
Floating point diveded by 2
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Floating point diveded by 2
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: Floating point diveded by 2
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
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Floating point diveded by 2
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.
Thanks for letting us know. I had a feeling it wouldn't be that simple but glad you tested it to be sure.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel