02-20-2012 06:23 AM
He he. Well, a *user* of a programming tool like LabVIEW is using the tool to develop programs, I guess. (Of course, I did not mean users of e.g. executables.) Even though I have been using LV for many years, I was not aware of the effect of multiplying integers. I am not a professional programmer. Same apply to most LabVIEW users, I guess. Same in Matlab: uint8(1000)*uint8(1000) produces 255, but noone would program this. In LabVIEW the integer data type is much more apparent to the user, and therefore the problem is more probable. In my application, I was to multiply integers 24 and 3600 to get number of seconds in one day (as a part of a control program for a biogas reactor). Could not understand why results were wrong...
02-20-2012 06:26 AM
I totally agree that one solution is to become a better programmer 🙂
02-20-2012 06:40 AM
@finnh wrote:
...as a part of a control program for a biogas reactor). Could not understand why results were wrong...
I'm not sure I want to be close to this biogas reactor if you're programming it's control program.
If you have a bottle that holds 1l and you pour 3l in it what happens? Overflow... Same thing with integer data types. If the "container" isn't big enough it'll overflow, which in integer calculation will not result in saturation but in wrapping.
02-20-2012 07:05 AM
We have obviously survived so far, but I'll definitely go through my program. You are right - If you ask someone to give you a bottle to hold 1 L + 1 L, you would *not expect* to get a bottle capable of holding only 1 L.