Matrix of insanity

I have been working at the university doing some "research" for some years now. I made some bad choices by choosing and starting to use the MATrix LABoratory or Matlab. It must have cursed my soul because I still like to use it...
Still with all the bad support responses, weird problems, bad performance etc. the typing system is what I don't really get over with. With all the other bad programming languages this s*** tops with madness.
All right, short trivia here should say enough. What are the outcomes of these operations?
a = uint8(12)  13
class(a)a = uint32(12)  uint8(13)
class(a)a = uint32(12)  double(13)
class(a)a = single(12)  double(13)
class(a)a= uint32(2^32) + 1
class(a)a= double(1) + uint32(2^32)
class(a)

It must have cursed my soul because I still like to use it...
There is still a chance for you, convert to NumPy and Scipy and lord Jupyter will save your soul. Even the documentations look very much like MATLAB, but instead of a university language you will be using a proper generic language (Python) that you can use for everything else. It will help you find a job in many currently hot Data Mining companies. Teachers do their students a disservice by using a subpar technology (MATLAB). It used to have better graphing but with MatplotLib you have a better solution now. Even better is that you can combine it with Cython and avoid writing hardtowrite mex files.

What are the outcomes of these operations?
I was told there would be no math.
I don't understand what you're saying. Shouldn't we see the results to make the WTF clear?

The lack of results is the
realintendedactual.

I've never used Matlab, so I'm totally lost here. You're saying that if you do those things nothing happens? Errors? Crash?

No clue, me either; I was referring to the OP's lack of results/an explanation.

I thought it was pretty clear: we're supposed to guess.

My guess was
uint8
,uint32
,uint32
,single
,uint32
anddouble
but tried in Octave the last one isuint32
which is the ? I will not pay for MATLAB, so cannot say what MATLAB will do.
Also in Octavea = uint32(12)  uint8(13)
throws an error because Octave is a secondhand MATLAB and thus even a worse choice to use.

My guess would be : runtime error, runtime error, double, double, runtime error, double.
And Octave is right to blow up on that.

And Octave is right to blow up on that.
Considering that Octave is supposed to be a MATLAB substitute, being right means it has to mimic MATLAB.

I guess they're all C#
TimeSpan
s.

I haven't touched Matlab since I finished my Statistics for Biosciences course, and I don't recall ever having to figure out these issues, so I dunno. I'm just glad I don't have to use the damn thing.


And the answers to the trivia. Now these little details allow you to easily make nice "little" errors to your data. Anyone have any ideas how to calculate hashes with this language?
a = uint8(12)  13
> 0 as uint8a = uint32(12)  uint8(13)
> Errora = uint32(12)  double(13)
> 0 as uint32a = single(12)  double(13)
> 1 as singlea= uint32(2^32) + 1
> 4294967295 as uint32a= double(1) + uint32(2^32)
> 4294967295 as uint32

Looks like it just sticks with the type on the left hand side and doesn't allow subtracting unsigned types, right?

Anyone have any ideas how to calculate hashes with this language?
[code]function digest = md5(message)
% digest = md5(message)
% Compute the MD5 digest of the message, as a hexadecimal digest.% Follow the MD5 algorithm from RFC 1321 [1] and Wikipedia [2]. % [1] http://tools.ietf.org/html/rfc1321 % [2] http://en.wikipedia.org/wiki/MD5 % m is the modulus for 32bit unsigned arithmetic. m = 2 ^ 32; % s is the shift table for circshift(). Each shift is negative % because it is a left shift. s = [7, 12, 17, 22 5, 9, 14, 20 4, 11, 16, 23 6, 10, 15, 21]; % t is the sine table. Each sine is a 32bit integer, unsigned. t = floor(abs(sin(1:64)) .* m); % Initialize the hash, as a row vector of 32bit integers. digest = [hex2dec('67452301') ... hex2dec('EFCDAB89') ... hex2dec('98BADCFE') ... hex2dec('10325476')]; % If message contains characters, convert them to ASCII values. message = double(message); bytelen = numel(message); % Pad the message by appending a 1, then appending enough 0s to make % the bit length congruent to 448 mod 512. Because we have bytes, we % append 128 '10000000', then append enough 0s '00000000's to make % the byte length congruent to 56 mod 64. message = [message, 128, zeros(1, mod(55  bytelen, 64))]; % Convert the message to 32bit integers, little endian. % For little endian, first byte is least significant byte. message = reshape(message, 4, numel(message) / 4); message = message(1,:) + ... % least significant byte message(2,:) * 256 + ... message(3,:) * 65536 + ... message(4,:) * 16777216; % most significant byte % Append the bit length as a 64bit integer, little endian. bitlen = bytelen * 8; message = [message, mod(bitlen, m), mod(bitlen / m, m)]; % Process each 512bit block. Because we have 32bit integers, each % block has 16 elements, message(k + (0:15)). for k = 1:16:numel(message) % Copy hash. a = digest(1); b = digest(2); c = digest(3); d = digest(4); % Do 64 operations. for i = (1:64) % Convert b, c, d to row vectors of bits (0s and 1s). bv = dec2bin(b, 32)  '0'; cv = dec2bin(c, 32)  '0'; dv = dec2bin(d, 32)  '0'; % Find f = mix of b, c, d. % ki = index in 0:15, to message(k + ki). % sr = row in 1:4, to s(sr, :). if i <= 16 % Round 1 f = (bv & cv)  (~bv & dv); ki = i  1; sr = 1; elseif i <= 32 % Round 2 f = (bv & dv)  (cv & ~dv); ki = mod(5 * i  4, 16); sr = 2; elseif i <= 48 % Round 3 f = xor(bv, xor(cv, dv)); ki = mod(3 * i + 2, 16); sr = 3; else % Round 4 f = xor(cv, bv  ~dv); ki = mod(7 * i  7, 16); sr = 4; end % Convert f, from row vector of bits, to 32bit integer. f = bin2dec(char(f + '0')); % Do circular shift of sum. sc = mod(i  1, 4) + 1; sum = mod(a + f + message(k + ki) + t(i), m); sum = dec2bin(sum, 32); sum = circshift(sum, [0, s(sr, sc)]); sum = bin2dec(sum); % Update a, b, c, d. temp = d; d = c; c = b; b = mod(b + sum, m); a = temp; end %for i % Add hash of this block to hash of previous blocks. digest = mod(digest + [a, b, c, d], m); end %for k % Convert hash from 32bit integers, little endian, to bytes. digest = [digest % least significant byte digest / 256 digest / 65536 digest / 16777216]; % most significant byte digest = reshape(mod(floor(digest), 256), 1, numel(digest)); % Convert hash to hexadecimal. digest = dec2hex(digest); digest = reshape(transpose(digest), 1, numel(digest));
end %md5[/code]
Doesn't look too bad...especially since you can see all the math, right there...