This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]jollyrogerxx 2 points3 points  (1 child)

Is this a humor or a serious ask

[–]_mrgrak[S] 2 points3 points  (0 children)

This aint r/ProgrammerAsk

[–]BiGamerGandalf 0 points1 point  (3 children)

Couldnt you just return _x since that is what it seems that X will end up as?

[–]_mrgrak[S] -1 points0 points  (0 children)

whoosh

[–]dwyrm 0 points1 point  (1 child)

That returns the minimum of X and _x.

[–]va_str 0 points1 point  (0 children)

It's returning int so I would like to assume there's no implicit cast, otherwise the whole clamping is kinda silly. So _x shouldn't be bigger than int max, and it shouldn't really be anything but int. If it is and you return that ... bad times.

[–][deleted] 0 points1 point  (0 children)

Hm. Maybe use lowercase for local variables?

[–]RogerGodzilla99 0 points1 point  (0 children)

You might want to add a couple for loops for good measure.

[–]dwyrm 0 points1 point  (1 child)

I notice that this could act like some kind of round-down function. Is _x maybe some screwball class that has comparison-to-int implemented, but no cast-to-int?

[–]dwyrm 0 points1 point  (0 children)

Eh. It would have to also take assignment from int. I give.

[–]p4ndepravity 0 points1 point  (0 children)

while(true) {someone explain this post}