Everything else that doesn't fall into one of the other PB categories.
-
Hroudtwolf
- Addict

- Posts: 803
- Joined: Sat Feb 12, 2005 3:35 am
- Location: Germany(Hessen)
-
Contact:
Post
by Hroudtwolf »
Hallo Comunity,
Can anyone explain me , how to convert a negative value to a positive ?
Thanks for your answer ...
-
El_Choni
- TailBite Expert

- Posts: 1007
- Joined: Fri Apr 25, 2003 6:09 pm
- Location: Spain
Post
by El_Choni »
El_Choni
-
dracflamloc
- Addict

- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
-
Contact:
Post
by dracflamloc »
That works in pb?
In general you will need to do something more like:
value=value*-1;
Which is what Choni's example does anyway, but this is non-specific to PB.
-
Hroudtwolf
- Addict

- Posts: 803
- Joined: Sat Feb 12, 2005 3:35 am
- Location: Germany(Hessen)
-
Contact:
Post
by Hroudtwolf »
thanks @ALL.
I got the answer already in PureBasic-Lounge.
-
El_Choni
- TailBite Expert

- Posts: 1007
- Joined: Fri Apr 25, 2003 6:09 pm
- Location: Spain
Post
by El_Choni »
At least in x86 CPUs multiplying a value takes more time than negating it. In my mind, too

El_Choni
-
traumatic
- PureBasic Expert

- Posts: 1661
- Joined: Sun Apr 27, 2003 4:41 pm
- Location: Germany
-
Contact:
Post
by traumatic »
dracflamloc wrote:That works in pb?
In general you will need to do something more like:
value=value*-1;
Which is what Choni's example does anyway, but this is non-specific to PB.
What do you mean?
Code: Select all
#include <stdio.h>
int main(int argc, char* argv[])
{
long value = 12345;
value *= -1;
printf("value: %d\n", value);
value =- value;
printf("value: %d\n", value);
value =~ value+1;
printf("value: %d\n", value);
return 0;
}
Good programmers don't comment their code. It was hard to write, should be hard to read.
-
Fred
- Administrator

- Posts: 18162
- Joined: Fri May 17, 2002 4:39 pm
- Location: France
-
Contact:
Post
by Fred »
"value = -value" is probably the fastest (and easiest) way to reverse sign in PB.
-
Falko
- Enthusiast

- Posts: 271
- Joined: Sat Oct 04, 2003 12:57 pm
- Location: Germany
-
Contact:
Post
by Falko »
Last edited by
Falko on Fri Apr 08, 2005 8:24 am, edited 1 time in total.
-
Rings
- Moderator

- Posts: 1435
- Joined: Sat Apr 26, 2003 1:11 am
Post
by Rings »
SPAMINATOR NR.1
-
leo1991
- New User

- Posts: 7
- Joined: Tue Feb 24, 2004 7:25 pm
Post
by leo1991 »
-
dige
- Addict

- Posts: 1391
- Joined: Wed Apr 30, 2003 8:15 am
- Location: Germany
-
Contact:
Post
by dige »
:lol: nice link Rings ...