add Int8 and int16
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
how can I write a code for this:
By default, it is not possible to add an int8 value to an int16 value. Write a function that accepts an int8 argument and an int16 argument and adds them together, returning the resulting value as an int16 value.
what I started to write:
function out2=add_int(in1,in2)
%Write a function that accepts an int8 argument and an int16
%argument and adds them together, returning the resulting value as an int16 value.
out=int8(in1)+int16(in2);
out2=int16(out);
0 Kommentare
Antworten (2)
Stephen23
am 18 Mär. 2021
add_int(int8(127),int16(129))
function out = add_int(in1,in2)
out = int16(in1) + int16(in2);
end
3 Kommentare
Bjorn Gustavsson
am 18 Mär. 2021
Think about what input variables you have, what type they have and which one you need to cast to another data-type.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with Control System Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!