“Floating” in Rubies.
Does my title give you the image of Ducktale’s Uncle Scrooge swimming in Rubies? I hope so!
If you want to get to the point of this article, then skip this paragraph, but otherwise a few words of introduction. This is my first article on Medium. The web development school I attend recommends writing as a way to improve your knowledge of things (and perhaps get noticed by a possible employer). The idea is if you can writing about something, you will internalize it more, and even get better at explaining things to others. Also, I used to write a lot of research papers! I have two liberal arts degrees and once wrote a lot in MLA style. Yet, I have often been told that I should blog since blogging first became a thing, but up until now I have resisted. Therefore, my writing is rusty, but if you hang with me I might get better. Let’s begin!
This short article is about Ruby’s #to_i method. I am studying web development and have used this method successfully a few times, but one day recently I discovered something. This method will occassionally round numbers, or integers more specifically, down! In coding with this Ruby method, I can imagine this trips people up because it’s so counter to our daily lives. “9.6 becomes 9? What?!!!”
If that does not strike you immediately, let me explain; almost everything we do in 21st century America involves rounding up! I can not think of any common task where we as a society round down. Think about checking out almost anywhere in America since 2020. “Ma’am, would you like to round up your bill to the nearest dollar and donate to our charity?” They never ask your permission to round down to save you money and donate the difference to their charity! So, do not let this mess you up! File this away somewhere for when you are working with integers.
Finally, if someone knows the method that would round 9.6 up to 10, please tell this coding newbie what it is in the comments. Thank you for reading.