Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Negative Variable

Author
Message
SEN
18
Years of Service
User Offline
Joined: 18th Jul 2006
Location:
Posted: 18th Jul 2006 09:34
The following DarkBASIC Classic code fails at line 2:

A=10
B=-A

How can we make B the negative of A?
flock
19
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 18th Jul 2006 12:26
You can do this...



This...



Or maybe this...



I'm sure there must be a simpler way... Anybody?

a.k.a. "flockhound"
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 18th Jul 2006 13:25
How about this:

B = 0 - A

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 18th Jul 2006 16:50
The example in the first post would work in DBP, but I guess DBC didnt have support for that at the time. Scen B's seems the simplest.

You could make a function to make it easier in the future;



That should work.


Projects: Online CTF Game | Newcommer's Guide to FPS's

Login to post a reply

Server time is: 2025-05-25 10:22:53
Your offset time is: 2025-05-25 10:22:53