Yep you are right. I created this without thinking about, your function is indeed better. But afaik you should use 1000 because this var use kilobyte and not kibibyte but I´m not sure.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com