Forum: Object-Pascal / Delphi-Language
Delphi
by Namenloser,
2. Dez 2013
I think in Delphi the upcast is done automatically by the compiler when the result is stored in a variable that is bigger than the operands.
var
b: Byte;
i: integer;
begin
b := 255;
i := b shl 2;
// i should now hold the value 510
Forum: Object-Pascal / Delphi-Language
Delphi
by Namenloser,
2. Dez 2013
I am not sure what you mean by that sentence, "whare" was not a word last time I checked ;).
I assume you wanted to say that the typecasts are unnecessary, which may be true. I didn't examine the code that closely, I was just saying that you should pay attention to that.
Forum: Object-Pascal / Delphi-Language
Delphi
by Namenloser,
2. Dez 2013
Looks mostly good to me, but I would pay some extra attention to the type casts. I am not sure if ord() always gives the correct result here. In some places the type cast might be done to truncate a value. For example, (ushort)foo gives us the lowest 16 bits of foo.
And in the top code, I think you can get rid of ord() entirely, if you've correctly translated char as byte.