Possible to take a logarithm?

fxer

Member
Pantsgiving has what appears to be a logarithmic counter, is it possible to take a log in Mafia? The formula I'm working with is:

floor(log10(pansgivingCount*2)) = pantsgivingFullness

some example output:
4=0
5=1
49=1
50=2
4999=3
5000=4
...

Where if you plug in your turns spent with Pantsgiving equipped (pansgivingCount), it will tell you how many fullness you should be able to acquire once you are at fullness_limit() in combat


http://kol.coldfront.net/thekolwiki/index.php/Pantsgiving
 

Winterbay

Active member
Well, you can use mathlib from here but that only gives you the natural log and not the 10-log (and also has not been updated since 2010...).
 

xKiv

Active member
This is a single=purpose ugly hack, but might work (I chose "*2))-1" instead of "/5))" in order to make it work with 0).
Code:
length(to_string(pantsgivingCount*2))-1

Will probably be faster and more accurate than limited-precision floating-point ln(pantsgivingCount*2)/ln(10).
 

lostcalpolydude

Developer
Staff member
Code:
int pgCount = get_property( "_pantsgivingCount" );
int pgFull = 0;
while ( pgCount >= 5 )
{
	pgCount /= 10; // pgCount = pgCount / 10
	pgFull += 1; // pgCount = pgCount + 1
}

That will get you what you want. But xKiv's code is simpler, I would probably go with that.
 

fxer

Member
This is a single=purpose ugly hack, but might work (I chose "*2))-1" instead of "/5))" in order to make it work with 0).
Code:
length(to_string(pantsgivingCount*2))-1

That hack is so nasty it's genius, thanks xKiv :)
 

xKiv

Active member
Often close-but-not-exact is how I think of all floating point values.

Problem in this case is, close-but-not-exact can sometimes mean the difference between getting the correct answer (N) and getting one less than the correct answer (N-1), because of how the rounding works.
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
�� r20310
 
Top