A few days ago I was working on a project where it was crucial that all the item prices ended up with a 9 after a discount coupon was redeemed, in need for an quick way to round any given number to the closest nine I did a couple of searches on Google and on the PHP Manual and I found the following formula:
round($number / $nearest) * $nearest;
Seemed pretty much straightforward the only problem is… It didn’t worked as I wanted it to! Imagine that $number is 212 and $nearest is 9 for example, the expected result for this scenario should be 209, since 212 is closer to 209 than to 219. However simple arithmetic tell us that:
round(212 / 9) * 9 = 24 * 9 = 216
Continue reading ‘Round to the Nearest - Digit or Multiple?’
Yesterday I got my hands on my very first Lincoln (five dollars) bill, they seem much more older and used than Euro banknotes. As I had already made a Euro note serial number validation algorithm in PHP I thought: “why don’t I do the same for dollar bills?”.

Continue reading ‘My first five Dollar Bill’
My sister just showed me this little math trick, it’s fun - try it out with your friends and share your experience here.
Continue reading ‘Math “Magic” Trick’
Hello there, I’m finally home! I’m kinda tired from the train trip but hopefully my bed will give me my deserved rest tonight…

Continue reading ‘I’m back from Lisbon!’

Have you ever come across a fake Euro banknote? Well, most of us probably have (at least those of us who live in the European Union, like me) - more than 300 thousand Euro banknotes are falsified every year.
Continue reading ‘Euro banknote validation with PHP’
Prime numbers have always been a central point of mathematical studies as they yield (at least for now) lots of stuff that we don’t understand (like factoring and it’s distribution among natural numbers - read the Wikipedia link bellow if you want to find out more). Prime numbers also play a big role paper in our world, as strange as it seems, our unability to fully understand primes is the basis of our digital security as we know it today. Finding new prime numbers nowadays is a task that no longer can be done by humans (as far as I’m aware of) and a computer takes at least a couple of days to find a new one.
Continue reading ‘Mersenne Prime Search’
I’ve just finished my PHP Math Library and Abstraction Layer, I’ve been up all night in order to code it, but it was worth it. I am proud of it.
My PHP Math Library features the following:
Continue reading ‘PHP Math Library’
Recent Comments