Allow floating-point division by zero in ZScript

Moderator: GZDoom Developers

User avatar
AFADoomer
Posts: 1325
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Re: Allow floating-point division by zero in ZScript

Post by AFADoomer »

You are correct. I started with a different example, and ended up putting the max in the wrong place when I changed it up...
argv
Posts: 184
Joined: Tue Aug 30, 2016 4:47 pm

Re: Allow floating-point division by zero in ZScript

Post by argv »

AFADoomer wrote:For brevity's sake, I usually end up putting in a "max([divisor that might end up as zero], [arbitrary small number]);" call in cases like this...

e.g.:

Code: Select all

TweenChange = 1. / (max(time, 0.0001) * TICRATE);
Not sure if that slows things down internally any more/less than using if statements to the same effect, but I haven't noticed any issues so far.
Good idea. As Graf confirmed, that's faster than if branches.

I've replaced the if with similar code:

Code: Select all

TweenChange = 1. / (max(time, double.epsilon) * TICRATE);
Thanks for the idea. :)
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”