0

I found in Matlab, uint8(n) / uint8(255) == 0 when n <127, while uint8(n) / uint8(255) == 1 when n >=127. I don't know how this happened. Since in C/C++, it should be 0 as long as numerator is less than denominator.

Can anyone help me, please?

Thanks!

wking
  • 1,293
  • 1
  • 16
  • 27

1 Answers1

2

Here, in the documentation:

MATLABĀ® rounds the results when dividing integer data types.

showing that MATLAB is not C or C++.

But you can use the idivide function and have control over rounding.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720