How to eliminate the error caused by converting double to uint16

조회 수: 7 (최근 30일)
CoderMinga
CoderMinga 2023년 10월 14일
댓글: Walter Roberson 2023년 10월 14일
How to eliminate the error caused by converting double to uint16
  댓글 수: 6
Dyuman Joshi
Dyuman Joshi 2023년 10월 14일
I see, "convert" is used generally, where as "map" is used particularly when trying to convert numbers outside the range of an integer class.
Walter Roberson
Walter Roberson 2023년 10월 14일
Consider, though, that (for example) π is within the numeric range 0 to 65535 so if you were using "convert" for in-range but "map" for out of range, you would have to use "convert" for π . uint16(pi) is of course uint16(round(pi)) which is 3 and there are a lot of other nearby values like that also get changed to 3. So even within the range 0 to 65535 the mapping is not "one to one and onto". It would not be unreasonable to argue that "convert" is possibly the wrong verb when the conversion is not bijective, that "map" might be a more appropriate verb -- but that "map" should be used throughout, not just for values outside of the range 0 to 65535.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by