once again doing work on the weekend for some reason

at least this problem is actively interesting enough to make me want to do it in my leisure time, I guess

even worse (from some perspectives, anyway) my weekend work is basically all math

just spent like two hours doing pure algebra to figure out and simplify a formula for computing the effective discount when buying Google's committed use discounts at different percentages of overall spend

probably would've been easier if I'd done any of this kind of math recently but eh. it's kinda fun working this stuff out from first principles

anyway, I keep having to write stuff like min(x, 0) or max(x, 1) to clamp values to a particular range and I feel like there should be clearer ways of writing this

I use min(x, 0) because it's shorter than if(x < 0, x), but min(x, 0) feels like it takes me a half second longer to grok

maybe I should just use if() for clarity of intent

@joe_no_body Definitely write those utilities for yourself. I 500% agree that there's just something about building clamp out of min and max that actively fights comprehension, and the time you will save not having to hunt down bugs caused by flipping them will more than make up for the cost of having one more function in your API.

(I still think the lack of clamp is the single largest missing piece in the Java standard library).

@mtomczak yeah. this is also entirely in a Google Sheet so maximizing comprehension feels really worthwhile considering how messy formulas can get

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.