A procedure from the bag of utilities used by Jeff Hobbs. Given an integer number it finds the smallest square greater than the input. A possible application for this is when a discrete number of items have to be displayed in a table. Using this returns the number of columns/rows for the table to fit all items.
1 2 3 4 5 6 7 8 9 10 11 12 | # get_square_size --
# gets the minimum square size for an input
# Arguments:
# num number
# Returns:
# returns smallest square size that would fit number
#
proc get_square_size num {
set i 1
while {($i*$i) < $num} { incr i }
return $i
}
|
Simpler version. Why not just: