[off-topic] math techniques ;) (was exp formula)

From: ;P (siv@CYBERENET.NET)
Date: 02/02/98


> >"exp = pow(2, level) * 1000" will give you something close to the above
>
> Ugh, try 'exp = level * level * 1000;'  It'll eliminate a function call,
> give the same results and not require the math library.

mmm...well..i meant 2^level (which is very different from level^2)..might
have had the pow call backwards :)

> Out you evil daemons of nested externs!
> (Try -Wnested-extern on CircleMUD and you'll see what I mean.)

so..i guess this is bad? any particular reason? it's used quite a bit
other places in the code (i'm thinking of nanny() in particular)..

> That seems like a lot of funny business casting your integers as floats all
> for nothing. Who cares how large your float is during processing if you
> just change back to an integer anyway?  (You also get warnings on that
> return line I believe, along the lines of lost precision.)

the reason i used floats was cause my int and wis mods were like .88 to
1.12..i guess i could just use 88 to 112 then divide by 100, shrug..
i think i had to type cast them to get them to actually work (not round
880 to 1000)..

if all other excuses fail..i did it a LONG time ago ;)

siv


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST