I just thought of a math problem for someone to try and solve:
a 32-bit signed integer can hold up to 10 places. - (+ or -) 2147483647 -
What would the formula be for reading or writing a digit in a multiple of 10 from said number.
I just thought of a math problem for someone to try and solve:
a 32-bit signed integer can hold up to 10 places. - (+ or -) 2147483647 -
What would the formula be for reading or writing a digit in a multiple of 10 from said number.
This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.
// num is the number in question
// place is the name for the digit you want, 1, 10, 100, etc. A well-formed place will be an integral power of 10, but let's not count on that
int get_digit (int num, int place)
{
if (place < 0)
// choke and die with nasty error
else if ( place < 10) return num% 10;
else return get_digit((int) num / 10, (int) place / 10);
}
// if you can guarantee that the number requested is 'well-formed'...
int get_digit(int num, int place)
{
return ((int) num / place) % 10;
}
// maybe you're expecting places named 0, 1, 2,... instead of 1, 10, 100...
int get_digit(int num, int place)
{
return ((int) num / pow(10, place)) % 10;
}
Last edited by Imzogelmo; 01-16-2013 at 05:31 AM.
Ahh. That's what I had! ..I could probably do one with exp10, log or something.. but I think this version is the best.
Anyhoo, what I was hinting to was; why not just treat MP like most rpg's do: Just a MaxMP and MP variable (with some maths for FF1). (That way I don't have to hack anything fancy in also.lol) :lazy:
This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.
There are currently 1 users browsing this thread. (0 members and 1 guests)