I have two constant inputs(5,90) of different data types(UInt16, Int16) to MinMax block in Simulink. When I simulate the model, its displaying answer as 4. I don't understand how its behaving. Can someone explain me.
조회 수: 1 (최근 30일)
이전 댓글 표시
I have two constant inputs(5,90) of different data types(UInt16, Int16) to MinMax block in Simulink. When I simulate the model, its displaying answer as 4. I don't understand how its behaving. Can someone explain me.
댓글 수: 1
Thomas Blackwood
2017년 6월 1일
편집: Thomas Blackwood
2017년 6월 1일
The Signed int16 and Unsigned uint16 have are a series of 0s and 1s that represent binary equivalent numbers of 2^15.
The Unsigned variable gives you straight binary 2^16 maximum value. You can count from 0 to (2^16 - 1) or 65535. (00000000 00000000 is reserved for 0 and 11111111 11111111 is 65535)
The signed variable assigns a -ve to one of the bits. This means you can get values below zero at the cost of reducing your counting range. Your range of values are from -2^15 to (2^15 - 1). (Something like 11111111 1111110 will be -32768 and 11111111 11111111 will be 32767)
The difference is one of the bits in Signed Integer is assigned to controlling whether the value is +ve or -ve.
Why is there a difference? Because the bits aren't adding up. If both your values are positive, try converting your Uint16 to a Int16. There should be a simulink block that does it.
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!