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.

Newcomers DBPro Corner / Display a number without the decimal point

Author
Message
stevenup 7002
18
Years of Service
User Offline
Joined: 26th Feb 2006
Location: Ireland
Posted: 22nd Mar 2006 22:17
Hey, probably somthing very simple but in my program, I have code for ammo that uses decimals. What I want to do is
But I don't want to show the decimal values after it. How do I do this?

Thanks in Advance,
-Steven

Founder Owner and President of Motron Games!
http://motronsoftware.com
SirFire
19
Years of Service
User Offline
Joined: 4th Apr 2005
Location: North America
Posted: 23rd Mar 2006 05:12
text 839,735,STR$ (int(ammo#))

spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 23rd Mar 2006 10:21
Ideally you should not use float values, ie fractional values, to store simple numbers like ammo, health, etc. Why would ammo be fractional like 4.3 ??

You should just use integers (whole numbers). So just ditch the # after the variable name and you get integers

Boo!
Euphoria
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: United Kingdom
Posted: 23rd Mar 2006 11:42 Edited at: 23rd Mar 2006 14:43
I have to agree with spooky there. You'll also find that if you use floats that you will end up with 4.4999999 ammo instead of 4.5 due to the wonders of number rounding

As an assumption are you storing clips & bullets in clip? Would be better using two integers there.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 23rd Mar 2006 14:34
One small search would bring up countless topics covering this;



Call that function for the Ammo# variable, or extract the code into your main loop. Either way, next time please do some searching before posting.

Login to post a reply

Server time is: 2024-11-27 23:30:52
Your offset time is: 2024-11-27 23:30:52