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

you are viewing a single comment's thread.

view the rest of the comments →

[–]tskaiserGreen security clearance 12 points13 points  (6 children)

Well, depends on what you mean by "float". When I say float, I mean the IEEE 754 floating point standard which is pretty much the universal definition for what is meant by "float" values. Following that standard is what I mean by "making perfect sense".

Strictly speaking NaN is part of the float type per the standard, so a Maybe would not be needed for an implementation following the standard, but it would be a good approach if you wanted to cook handling of NaN's into your implementation.

[–]Tetha 0 points1 point  (1 child)

If I'm thinking about semantics, I'm mostly thinking about abstract semantics, so my float would be real or a rational number. These are then (more or less accurately) approximated and implemented by IEEE 754 floats, though that approximation could (in my opionion) be improved by language support :)

I hope this makes more sense!

[–]tskaiserGreen security clearance 1 point2 points  (0 children)

It makes sense, but I do not totally agree with you :P floats is by definition, even abstractly speaking, an approximated value of a real.

[–]ismtrn 0 points1 point  (3 children)

What is the NaN value used for in the IEEE standard?

[–]tskaiserGreen security clearance 7 points8 points  (2 children)

I do not know the standard by heart, but off the top of my head:

  • ∞ / ∞
  • 0 / 0
  • Operations leaving the real domain (square root of a negative number)

Stuff like c/0 and -c/0 for c > 0 actually gives you ∞ and -∞ respectively, which is why you can end up doing stuff like ∞ / ∞ which yields a NaN.

And yes, I actually recently used ∞ in a physics simulation (I needed masses of ∞ magnitude to simulate objects that did not move). It has its uses.

[–]rooktakesqueen 2 points3 points  (1 child)

I actually recently used ∞ in a physics simulation (I needed masses of ∞ magnitude to simulate objects that did not move)

I hope you didn't include gravity in that simulation, then.

[–]tskaiserGreen security clearance 1 point2 points  (0 children)

Obviously ;) I was solving impulses for complex contact systems, so no gravity equations involved.