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.
3 ビュー (過去 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!