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!