Wiki source for OctaveIntegerArithmetic


Show raw source

=====Integer-Arithmetik unter Octave and MATLAB=====

Create a matrix containing Integer-Objects:
%%(matlab)
A = int8(randn(4,4)*10)
%%

||A*3||implemented||
||A.*A||implemented||
||A*A||not implemented||

Keine Möglichkeit die Eigenschaften von Rechenoperartionen einzustellen (z.B. Wahl zwischen Sättigung oder Überlauf bei Addition und Multiplikation)


Beispiel mit 16-Bit-Signed-Integer:

%%
>> a = int16(400)

a =
400

>> b = int16(1000)

b =
1000

>> a*b

ans =
32767
%%




Beispiel mit 8-Bit-Unsigned-Integer:
%%(matlab)
a = uint8(0);
for i=1:10;
a=a+50;
disp(a);
end
%%

Ausgabe:
50
100
150
200
250
255
255
255
255
255



Minimum und Maximum eines Integer-Wertes ermitteln.

Maximum
%%
intmax('int8')

ans =
127
%%

Minimum
%%
intmin('int8')

ans =
-128
%%


----
Siehe auch {{backlinks}}
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki