if started=true then started:=false; if started=false then started:=true;
Hello!The inc method would of worked if thought out a little differently
Is there any command for this:
if started=true then started:=false; if started=false then started:=true;
I tried the inc(); but it gave RunError...
Start := Boolean( Byte(Start)and 1);Obfuscation for the win! ;D
A more "simplified" version of GetMem's one line solution:
[…] I certainly hope that the OP […] doesn't think that it is in any way acceptable practice. […]Yeah, agreed. Especially – examining the assembler output – it produces “slow” and “bulky” code. I think, we need to optimize it using assembly language:
[…] I certainly hope that the OP […] doesn't think that it is in any way acceptable practice. […]Yeah, agreed. Especially – examining the assembler output – it produces “slow” and “bulky” code. I think, we need to optimize it using assembly language:%) :P
{$asmMode intel} asm xor started, 1 end;
What the compiler does behind closed doors is the business of nobody but the compiler and its consenting libraries.
However unless Ord(Succ(false)) is defined by the language to be 1 I'd be very uneasy about any negation based on Inc() or xor: it's almost universally accepted that false is represented by zero but in some languages Ord(not false) is -1 rather than 1.
What the compiler does behind closed doors is the business of nobody but the compiler and its consenting libraries.
However unless Ord(Succ(false)) is defined by the language to be 1 I'd be very uneasy about any negation based on Inc() or xor: it's almost universally accepted that false is represented by zero but in some languages Ord(not false) is -1 rather than 1.
For (Object) Pascal the types Boolean, Boolean8, Boolean16, Boolean32 and Boolean64 use 0 for False and 1 for True while the types ByteBool, WordBool, LongBool and QWordBool use 0 for False and "not 0" (or -1) for True.
while the types ByteBool, WordBool, LongBool and QWordBool use 0 for False and "not 0" (or -1) for True.Slightly more precisely, "all but zero", i.e. 1, 2, 100 and -100 also give True.