Earlier quoted context omitted.
I'm well aware of nonstandard analysis, but ∞ is still not a number there, even though there are infinitely many infinitely large elements .
The extended complex plane is a space where inf is actually number and where division by zero is allowed. Same with the extended real line. Infinity is as much a number as it is useful to define it as such.
How does your programming language handle “minus zero” (-0.0)?
81–90 of 219 posts
Re: How does your programming language handle “minus zero” (-0.0)?
#82Earlier quoted context omitted.
When does this need arise? Well, otherwise inverting a value can change it's sign and in particular inverting -∞ twice will give you +∞, and being off by "2∞" is a pretty large error for a lot of computations ;) You can end up with zeros and infinities pretty easily because you overflow or underflow the range of floating point precision, and generally you want something sensible to happen in typical cases, even if so…
> If anyone knows why this design was not chosen and what fundamental downsides it has, I'd love to hear it. No fundamental ones, but a few practical. 32-bit numbers have 2^32 unique values, the number is even. Your approach makes the range asymmetrical like it happens with integers. The range for 8-bit signed integers is [ -128 .. +127 ]. On ARM NEON there’re two versions of integer negate and absolute instructions,…
Re: How does your programming language handle “minus zero” (-0.0)?
#83Earlier quoted context omitted.
I never said it was easier and I never said ALL game engines. And computing integers IS faster than computing floats, at least on a CPU.
>And computing integers IS faster than computing floats, at least on a CPU. In the abstract yes. In reality not so much. A lot of what floats are used for in games is vector math (you are often in a 2D/3D world), and vector math in fixed point requires a lot more work in integer math since you constantly need to shift down things in order to avoid overflow. Overflow bugs are a constant problem when doing dot products…
If you try to do with Fixed Point Arithmetic what was intended to be done with Floating Point, you're the problem.
A 32 bits integer can hold values up to 4 billions, if I have that kind of value in a simple game, then yes i will switch to Floating Point Arithmetic, but when does that use case happen if you're not writing a physic simulation game ?
Re: How does your programming language handle “minus zero” (-0.0)?
#84I feel like floating point is a completely separate branch of programming that a lot of coders never use. When they do it's often a mistake, like for currency. Yet floating point is very useful for scientific calculations and simulations, which is what computers were all about for the first couple of decades. I have a suspicion that on a fundamental level, floating point isn't actually good for games or machine learn…
As someone who has started out making games on Playstation 1 that didn't have floating point hardware, I can with authority say that developing games with only integers suck. Floating point number are far easier and robust to use.
Re: How does your programming language handle “minus zero” (-0.0)?
#85I feel like floating point is a completely separate branch of programming that a lot of coders never use. When they do it's often a mistake, like for currency. Yet floating point is very useful for scientific calculations and simulations, which is what computers were all about for the first couple of decades. I have a suspicion that on a fundamental level, floating point isn't actually good for games or machine learn…
Re: How does your programming language handle “minus zero” (-0.0)?
#86But I see from the standard that dividing by zero returns infinity with the xor of the dividend and divisor. This also makes no sense - since zero has no sign, its not possible to tell what kind of infinity would result. It's strange that the standard permits both the infinity result from dividing by zero, and simultaneously supports signed zero.
Re: How does your programming language handle “minus zero” (-0.0)?
#87 php > $minus_zero = -0.0;
php > $plus_zero = +0.0;
php > var_dump(1.0 / $minus_zero);
PHP Warning: Uncaught DivisionByZeroError: Division by zero in php shell code:1Re: How does your programming language handle “minus zero” (-0.0)?
#88Earlier quoted context omitted.
As someone who has started out making games on Playstation 1 that didn't have floating point hardware, I can with authority say that developing games with only integers suck. Floating point number are far easier and robust to use.
Only integers? Wow. Were int pairs used to represent numbers with decimals or what?
Re: How does your programming language handle “minus zero” (-0.0)?
#89I feel like floating point is a completely separate branch of programming that a lot of coders never use. When they do it's often a mistake, like for currency. Yet floating point is very useful for scientific calculations and simulations, which is what computers were all about for the first couple of decades. I have a suspicion that on a fundamental level, floating point isn't actually good for games or machine learn…
Lots of the math in games and ML assumes you’re operating in the reals. For example, the optimization in neural networks. Integers and fixed point won’t work.
Re: How does your programming language handle “minus zero” (-0.0)?
#90PHP just refuses to divide by zero: php > $minus_zero = -0.0; php > $plus_zero = +0.0; php > var_dump(1.0 / $minus_zero); PHP Warning: Uncaught DivisionByZeroError: Division by zero in php shell code:1