The Daily Click ::. Forums ::. Klik Coding Help ::. Decimal Points
 

Post Reply  Post Oekaki 
 

Posted By Message

sizcoz



Registered
  22/11/2005
Points
  117
30th November, 2005 at 14:33:48 -

Is there anyway of implementing decimal points on TGF, or any extension you can use for decimals?

 
n/a

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
1st December, 2005 at 01:46:13 -

I'm not sure, but in the cases of decimals in KNP, I used to make a number a few times bigger than the amount of decimals I wanted to do.

Let's say I want like an arrow to do Dmg*Multiplier damage. Problem is, Multiplier is something that has to be a decimaled number with around 2 decimal points. This is what I'd do..

Assume Dmg = 3, Multiplier's supposed to be 1.35...

I'll set Alterable Value A (Damage) to 3
Alterable Value B (Multiplier) to 135

Damage = Dmg*Multiplier/100

The answer will still be correct. Not as accurate and not so easy, but it works if you don't have any alternative. I think a lot of other things in TGF and the old MMF use only integers.

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
1st December, 2005 at 07:40:03 -

This thread brings up a small question. I knew how at 1 point, but I forgot. How can you round a number's ammont of dec? Like 5.999 to 5.98?

 
http://www.facebook.com/truediamondgame

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
1st December, 2005 at 08:20:27 -

Well, unless MMF has an undocumented floor/ceiling function (and I really wouldn't know, I'd been using the squaring-rooting method instead of abs() up until recently), you could do a little recursive dealie that uses mod to check if the last digit >=5, strip it and add to the next order of mag.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
1st December, 2005 at 08:30:15 -

How dare you post while I'm editing.

 
n/a

sizcoz



Registered
  22/11/2005
Points
  117
1st December, 2005 at 13:57:39 -

The reason I ask, is suppose you were creating a game that was money orientated, how would you work out $1.50 x 3, and get a correct answer.

 
n/a

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
1st December, 2005 at 21:27:33 -

Like I wrote, store $1.50 as 150, then when you calculate, divide by 100. You'd have 150/100*3. And like Phizzy said, you can just move the decimal point there with a little string manipulation.

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
2nd December, 2005 at 03:41:00 -

Calculating it like that won't work if TGF can't support decimals at all. Use the string manipulation method.

 
http://www.davidn.co.nr - Games, music, living in America
   

Post Reply



 



Advertisement

Worth A Click