LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fixed-Point bug in LabView?

Solved!
Go to solution

Hello,

I'm currently working on a FPGA project in LabView and encountered something odd that seems like a bug, but it could also just be me not fully understanding how fixed-point numbers are supposed to work. I'm working in LabView 2010 Pro (10.0f2 32-bit) on Win 7 Ent. 64-bit.

 

The problem I have is that when I try to add certain numbers together I get unexpected answers, which of course makes the code very unreliable.

 

For example: If you try to Add 0.50002 with -0.49998 you would expect something around zero, but instead you get like 3.99999.... Am I missing something here? I've seen this on several numbers around zero. Does fixed-points not work around zero?

 

I should add that I've just tried this on the local machine and not on the FPGA, but I don't see that would make any difference. Both inputs are set to 'Adapt to entered data' and the output is 'Adapt to source', the Add-function is also set to 'Adapt to source' and I've tried both Wrap and Saturate.. I've also tried with fixed bits instead of Adapt to entered data on the inputs etc. with no luck.

 

Can anyone shred some light on this please? Is it just me or is it really a bug or just as fixed-point numbers are supposed to work?

 

Thanks!

/Joel

 

 

 

0 Kudos
Message 1 of 9
(4,080 Views)

Are you certain your FXP isn't unsigned? If it's unsiged that -0.5 will be a rather big number. 🙂

Can you post a VI showing the issue?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 9
(4,067 Views)

Thanks for your reply.

 

No it's set to 'Adapt to entered data', but I've tried with setting it to signed (32/1 bit) also and it makes no difference.

 

I attached the simple vi. I get same weird result for many numbers I try so don't know what's wrong..

 

/Joel

0 Kudos
Message 3 of 9
(4,062 Views)

I concur, even 0,50001-0,5 yields 7,999 or something crazy.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 9
(4,054 Views)

You can get around it by typecasting the answer to a FXP of appropriate format.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 9
(4,040 Views)

You mean by putting a 'Type Cast' after the 'Add'? Maybe, but that's not reasonable to do after every single aritmetic operation in a large program 😉

 

I don't know if I dare using fixed-points at all now if it's really a bug, it could cause some nasty results...  But then if it is bug loads of people should have noticed it already I guess, so there has to be some explanation 😛

0 Kudos
Message 6 of 9
(4,035 Views)
Solution
Accepted by topic author Elrahir

It is not a bug.  If you expand the indicator displaying the result, you will see that there is an exponent of -5 at the end (e-5 = 10^-5).    So it is telling you the answer is 4*10^-5 or 0.00004, which is pretty close to 0.

 

Result.png

Message 7 of 9
(4,025 Views)

Ohhhh... *facepalm* 

 

Haha thanks, that explains it 😉

Message 8 of 9
(4,022 Views)

 


@Elrahir wrote:

Ohhhh... *facepalm* 

 

Haha thanks, that explains it 😉


Smiley Very HappySmiley Very Happy

 

That comment just made my morning!  Thanks.  For some reason I've got a vision in my mind from a vegetable drink commercial. 

"Oh! (*facepalm* ) I could've had a VU8."

 

 


"Should be" isn't "Is" -Jay
Message 9 of 9
(3,950 Views)