Negative number

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Negative number

Post by kettle_drum »

Dont know if im just not seeing it, but is there a function to turn a possitive number into a negative? E.g. 12 will become -12 or do we just have to subtract the value from itself twice?
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

-
Hi,

I don't know any. But your idea to substract the value twice from itself was funny to me :) Why not just multiply with -1 ?

djot
-
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Hmm interesting...lol. That might be a better idea :P

Code: Select all

$value *= -1;

not 

$value -= ($value*2);
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

kettle_drum wrote:Hmm interesting...lol. That might be a better idea :P

Code: Select all

$value *= -1;

not 

$value -= ($value*2);
Sometimes the obvious is the unobvious.. if that makes sense :P
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Phenom wrote:Sometimes the obvious is the unobvious.. if that makes sense :P
Like known knowns and known unkonwns and unknown knowns and unknown unknowns. ;)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

But the unknown is known unless the known is known and unknown not known while the unknown is unknown
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

The unkown will remain unknown unless known.

(that's it from me - don't want to derail this thread further ;) )
Post Reply