Cookie Thread Act 3: The Cookie Strikes Back

zug is there a not stupid way to round to the not nearest number. like 8.1 rounds to 9. 8.9 rounds to 8
like i guess you could do trunc(trunc(x) + (1 - (x - trunc(x))) + 0.5) but like. this feels silly. this is silly

flipping the fraction part and doing a standard rounding algorithm feels wrong. surely theres a simpler way

trunc(x+0.5)

assuming trunc removes the fractional part

oh wait i read that wrong :joy_cat:

mmmm that’s an interesting problem

no that rounds to nearest

8.6 + 0.5 = 9.1
trunc(9.1) = 9

im looking for 8.6 outputting 8

1 Like

all the ways i’m thinking of are probably equally complicated thbhtbhtbthbthbththb

what are you cooking

What practical use this has, if you find a solution?

trunc(x) + ((trunc(2x) + 1) % 2)

this does break integers though

practical uses are boring
i love impractical math

1 Like

I wonder what real life practice even exists for root square numbers?

If you’re doing Java, you can just cast it to an integer.

Oh, wait, I see what you’re doing.

You might laugh, but we used pythagoras principle, when we made the garage in our garden, so we will make sure it becomes a perfect rectangle. (Pythagoras uses square root, just for giving you an IRL example.)

1 Like

Maybe then something like:

public int roundWrong(double number) {return -((int) -8.6);}

That’s still gives 9, doesn’t it?

I suppose! But besides geometry?

I think it rounds up to -8?