Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "math base"
My boss has been begging me migrate a nightmarish complex excel report he made to calculate the payout of a tiered rebates program with compounding rewards. Today I finally decided to make take the time and I sat down with him so he could break it down for me...
Me: *looking at the mess of formula's* it would be easier to rewrite the math than decode this - can you just give me the reward rules... where does that value in cellX come from?
Him:*pointing at the spreadsheet* There! All the rules are in there for you :-)... like it's some big favour...
Me:No I mean when you wrote this, what did you base this off? There must be something...
Him: *Very Gravely* No, no, no it's far to complex! It took me ages to get this sheet right and it balances so just trust me and use it ok?
At this point I will mention he's an accountant so yeah I fucking trust him... fast forward past 15 minutes of digging through what may as well be quantum theory and lo and fucking behold all 2 sheets and 100 calculations are mathematically fucking pointless. Aside from formulas like this:
which is actually equal to (X10/R4)/L10.
Anyway once you compound and sum the "tiered" benefits the rewards payout is ALWAYS = customerSpend*1.81.
This is why programmers name variables.
To people who like binary and numbers!
For me it's a lot because I'm not that good. And last week at uni I learn numbering systems, and how to convert a decimal base number into other bases.
So yeah, I made a function that turns decimal numbers into binary ones!
To me it's a HUUUGE step!
It's probably not the prettiest code (I'll refactor it other day), but here it is if you want to see (GitHub):
How hard can it be to make a calculator app. Apparently Microsoft cannot get it right. You might say hey, but it works already. No it does not. See in math 1-(-1)=2 because the double minus sign cancel each other and turn into a plus. Well the w10 calculator app, just does 1-1=0 and show that this is the result. Yes this is the result of one minus one. This is not the result of one minus minus one. This is basic math .... Stop focusing on the interface and code the base right Microsoft.15
can we just get rid of floating points? or at least make it quite clear that they are almost certainly not to be used.
yes, they have some interesting properties that make them good for special tasks like raytracing and very special forms of math. but for most stuff, storing as much smaller increments and dividing at the end (ie. don't store money as 23.45. store as 2,345. the math is the same. implement display logic when showing it.) works for almost all tasks.
floating point math is broken! and most people who really, truely actually need it can explain why, which bits do what, and how to avoid rounding errors or why they are not significant to their task.
or better yet can we design a standard complex number system to handle repeating divisions and then it won't be an issue?
footnote: (I may not be perfectly accurate here. please correct if you know more)
much like 1/3 (0.3333333...) in base 10 repeats forever, that happens with 0.1 in base 2 because of how floats store things.
this, among other reasons, is why 0.1+0.2 returns 0.300000046
I'm curious, how many of you ranters out there studied Math at an advanced level to become proficient at programming? Is there a particular field of Mathematics that would improve my programming skill?
Context: I come across a lot of Math I don't understand/never encountered when researching topics such as encryption, hashing, geospatial data handling and randomness. Was wondering if I missed out on some key learning that would make these topics a lot less mysterious. Also, I overheard someone coming up with a mathematical formula to base an algorithm on. I don't think I've ever come up with algos this way.6
I know it's not really related to development, but I got in a discussion on twitter and one dude tweeted "in science, 1 isn't 1"
And so I was like "mate what? science is highly dependent on math and in math, 1 is kinda always worth math"
And this this girl comes in and just says:
"it's not true that 1 is always 1 because there's binary code as well"
And was was like totally astonished, like, have you even studied something? 1b = 1d = 1x and it's always 1 in whatever base!
(she even says she's some sort of engineer in her bio)8