Page 1 of 3

Invert Value or however you want call it...

Posted: Tue Sep 27, 2005 10:49 pm
by va!n
Code updated for 5.20+

i was asked how to set a positive value to a negative and backward... here is my small idea...

Code: Select all

Procedure InvertValue(val)
  ProcedureReturn val - (val+val)
EndProcedure

Debug InvertValue(24)      ; returns  -24
Debug InvertValue(-318)   ; returns   318

Posted: Tue Sep 27, 2005 10:59 pm
by fweil
It works well but it is just 5 or 6 times slower than a = -a

Posted: Tue Sep 27, 2005 11:04 pm
by va!n
fweil wrote:It works well but it is just 5 or 6 times slower than a = -a
ok, thanks :wink:
it was made in a real hurry for a friend...

Posted: Wed Sep 28, 2005 9:36 am
by Psychophanta
Va!n,
Sorry; With all my respects; i think these kind of tricks are too simple.
I'd add 'Beginners' word before the title of the thread, or a way to say the skill degree of the trick (tip) or something.
Just only my opinion :?

Posted: Wed Sep 28, 2005 12:01 pm
by Dare2
@Psychophanta,

Stop criticising and start contributing!

:P :D

Posted: Wed Sep 28, 2005 12:06 pm
by Fred
Psychophanta wrote:Va!n,
Sorry; With all my respects; i think these kind of tricks are too simple.
I'd add 'Beginners' word before the title of the thread, or a way to say the skill degree of the trick (tip) or something.
Just only my opinion :?
+1 :)

Posted: Wed Sep 28, 2005 2:35 pm
by Trond
If you want to write really obfuscated code you can use this:

Code: Select all

a-a-a
:wink:

Posted: Wed Sep 28, 2005 6:18 pm
by Tranquil
Dare2 wrote:@Psychophanta,

Stop criticising and start contributing!

:P :D
*thumb up*

YES !

Posted: Wed Sep 28, 2005 7:11 pm
by netmaestro
Psychopanta, you are forgetting an important point. Adding the word "beginner" to the post means one more word for the browser to process and that eats up valuable CPU time! :lol:

Posted: Wed Sep 28, 2005 7:30 pm
by fweil
@netmaestro,

You mean that laziness means better CPU performances ?

I should beat 128bits CPUs planned for the next decade ...

Posted: Wed Sep 28, 2005 7:36 pm
by Psychophanta
:lol:

Posted: Wed Sep 28, 2005 7:39 pm
by fweil
I ever thought that clever people are lazy.

Just because lower eneergy comsuption means higher skills ...

Maybe you will notice that the shortest a philosophical sentence is, the largest signification it may have. It may, just ... pay if you want to know more. I am lazy, but if you pay I will explain you more.

Blue Screen !

Posted: Wed Sep 28, 2005 7:54 pm
by Psychophanta
fweil wrote:I ever thought that clever people are lazy.
Yes.
But that doesn't mean that lazy people are clever :D :P

Posted: Wed Sep 28, 2005 8:40 pm
by Trond
Psychophanta wrote:
fweil wrote:I ever thought that clever people are lazy.
Yes.
But that doesn't mean that lazy people are clever :D :P
Oh that's sad I was in heaven for a minute. :roll: :wink:

Posted: Thu Sep 29, 2005 1:40 pm
by Lebostein

Code: Select all

result.l = val - (val+val)
result.l = val - val - val
result.l = 0 - val
result.l = -val
:roll: