Converting decimal/integer to binary - how and why it works the way it does?
As already asked David in a comment of an answer here , I'm really interested on how this function works, since I can't seem to get the same (correct) values if changing result length from 32 to 16 or 8. I used function function IntToBin(Value: LongWord): string; var i: Integer; begin SetLength(Result, 32); for i := 1 to 32 do begin if ((Value shl (i-1)) shr 31) = 0 then begin Result[i] := '0' end else begin Result[i] := '1'; end; end; end; which somehow works just fine. (1 is returned as 000....001, 2 as 000....010, 3 as 000...011, etc...). However, since I only needed 8 chars long string