03-11-2021 06:47 AM
Hello everybody,
I noticed a potential bug with the function "Multiplier". Maybe there is a rational explanation but I don't see for this moment.
I did 80*10 and the result is 32 and not 800 ??? Why???
I joined a picture.
Thank by advance at the community
regards,
Régis
Solved! Go to Solution.
03-11-2021 07:07 AM
Your data type is a U8 or I8. The value is being rolled over and so you get 32 (800 mod 256 = 32).
03-11-2021 07:29 AM
Yes, the local variable with the number "10" is U8. I forgot. But I'm surprised the result was 32 and not 256?
I put U16 and my problem has been corrected.
I'm a stupid man. ^^
Thank you very much.
Have a nice day,
Regards,
Régis
03-11-2021 07:37 AM
It can't be 256 because a U8 can only b3 0-255.
It can't be 255 because when you do math on integers and the results go out of range, the value rolls over. It doesn't stay stuck at the max or min.
03-11-2021 07:43 AM
Ok, I understand better. Effectively, I thought the value blocked on max value 255 (and not 256, I did a mistake in my previous message, thank you for the correction).
Thank you a lot for your full explanation. Very clear.
I will sleep less stupid tonight ^^.
Have a nice day,
Regards,
Régis
03-11-2021 07:53 AM
@regis76 wrote:
Yes, the local variable with the number "10" is U8. I forgot. But I'm surprised the result was 32 and not 256?
The mathematical algorithm down in the processor does not do a range check. It will just do that mathematical process and stop once 8 bits have been defined.