You are viewing a single thread.
View all comments View context
2 points

It doesn’t have to “error” if the result case is offered and handled.

permalink
report
parent
reply
1 point

Float processing is at the hardware level. It needs a way to signal when an unrepresented value would be returned.

permalink
report
parent
reply
2 points

My thinking is that a call to the safe division method would check after the division, whether the result is a NaN. And if it is, then it returns an Error-value, which you can handle.

Obviously, you could do the same with a NaN by just throwing an if-else after any division statement, but I would like to enforce it in the type system that this check is done.

permalink
report
parent
reply
2 points
*

I feel like that’s adding overhead to every operation to catch the few operations that could result in a nan.

But I guess you could provide alternative safe versions of float operations to account for this. Which may be what you meant thinking about it lol

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 1.9K

    Monthly active users

  • 1.1K

    Posts

  • 39K

    Comments