Legacy GM Better way to set a row variable

I'm currently in the middle of coding the menu in an RPG where a character's spells are displayed and have ran into a small problem. All spells are stored in an array and the spells are shown on screen in rows of two like in Final Fantasy 6. I'm trying to come up with a way to always get the correct number of rows based on the amount of spells a character has.

My first thought was to just take half of the array length:

Code:
total_spell_rows = ( array_length_1d( global.char_battle_info[ CHAR_BATTLE_PROP.CBP_SPELLS, char_sel_party_pos ] ) /  2 );
However, in some cases this would lead to an inaccurate number of rows unless I use the round() function. I was just wondering if there was a better way to do this.
 

Nidoking

Member
That's pretty much how you do it - I use the ceil() function to ensure that I round up and create the extra row, but that's exactly how you determine the number of rows.
 
That's pretty much how you do it - I use the ceil() function to ensure that I round up and create the extra row, but that's exactly how you determine the number of rows.
Oh, okay I just wanted to make sure there wasn't a better way to do this. I'm not familiar with ceil() since I mostly stick with using round(). Just read up on both functions, and you're right its better to use ceil since with the round() function due to the banker's rounding thing. Thanks for the quick reply.
 
Top