Negative integers?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
tomshreds
Party member
Posts: 101
Joined: Thu Oct 18, 2012 8:49 pm

Negative integers?

Post by tomshreds »

Hi,

I was wondering, I need my in-game balance to go negative at some times in my game.

How could I do this? I'd like to be able to have a balance of -1450 for example. And then earn some money and go positive, etc.

Any idea?

Thanks!
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

Re: Negative integers?

Post by OmarShehata »

So...where's the problem?

Code: Select all

local balance = 10;
balance = balance - 100;
print(balance);
balance = balance + 200;
print(balance);
tomshreds
Party member
Posts: 101
Joined: Thu Oct 18, 2012 8:49 pm

Re: Negative integers?

Post by tomshreds »

OmarShehata wrote:So...where's the problem?

Code: Select all

local balance = 10;
balance = balance - 100;
print(balance);
balance = balance + 200;
print(balance);
Frankly, I was sure lua wasn't going to do this. So sure that I didn't tested it.

Thanks for this and sorry :-S
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Negative integers?

Post by Robin »

tomshreds wrote:Frankly, I was sure lua wasn't going to do this.
I'm really interested in what led you to that belief. Do you know why, or just have a good guess about it?
Help us help you: attach a .love.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Negative integers?

Post by T-Bone »

I think that every single programming language ever has supported negative numbers.
User avatar
YellowAfterlife
Prole
Posts: 29
Joined: Mon Jan 23, 2012 4:05 pm
Contact:

Re: Negative integers?

Post by YellowAfterlife »

T-Bone wrote:I think that every single programming language ever has supported negative numbers.
Some languages also support unsigned number types;
Some of RISC architectures may leave signed number implementation to programmer for various reasons.
yal.cc
Contains things I work on. Also gets Love2d examples time to time.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests