HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Complicated Arithmetic Question

11-18-2002, 03:04 AM#1
MrDoomMaster
I'm trying to deduct a preset integer variable by a percent, but since integers can't be decimal values (i guess) i find this hard to do. Is there anyway i can reduce an integer, like 45, by a percent?

Here is a method i have tried, But it doesn't work:

Set T2 = (1 - (1 / (number of players in Team2)))
Set Team2Kills = (Team2kills x T2)

If there is no way to use percentages, is there a way i can use decimals?

I appreciate all the advice i can get. Thanks for reading.
11-18-2002, 03:15 AM#2
Guest
There's serval things you can do..

A) Take your orginal numer and muliply it by 45, then divide by 100
B) Convert the orginal number to a real, multiply it by .45, then convert it back to an integer.

And lots more.. but basically yeah..
11-18-2002, 03:19 AM#3
Guest
Set T2 = R2I(1 - (1 / I2R(Number of players in Team 2)) * 100
Set Team2Kills = (Team2Kills * T2) / 100
11-18-2002, 04:51 AM#4
ph33rb0
Well converting reals to integers is risky business cause say your result is 20.7238 then that would not work as an integer... and I'm sure WC would round it but there's no way to tell if this could cause bugs...
11-18-2002, 07:51 AM#5
Sytadel
Fear hit the nail on the head - you can't simply convert it back to an integer, because WC tends to round numbers. Is it possible for you to just use a real variable throughout the map?
11-18-2002, 08:20 AM#6
Phil_123
convert real to string: (your varaiable here)
11-18-2002, 08:58 AM#7
Guest
Yeah, it does round, but that's no biggy, if it's X.0 - X.5 it goes to X, otherwise it goes to X + 1. It you always want to round up just add .5 to the number before you convert it to an integer, subtract .5 if you want to round down. Or just leave as is to round to the closest numer. Easy stuff.
11-19-2002, 12:14 AM#8
Aiursrage2k
Convert the integers to real values, then multiply by 100. Convert the real value back to integer if need be.

But why not simply work with real numbers in the first place.