[No] Allow floating-point division by zero in ZScript

Moderator: GZDoom Developers

Re: Allow floating-point division by zero in ZScript

Postby AFADoomer » Sat Jul 28, 2018 6:04 pm

You are correct. I started with a different example, and ended up putting the max in the wrong place when I changed it up...
User avatar
AFADoomer
 
Joined: 15 Jul 2003

Re: Allow floating-point division by zero in ZScript

Postby argv » Sat Jul 28, 2018 6:19 pm

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 allExpand view
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 allExpand view
TweenChange = 1. / (max(time, double.epsilon) * TICRATE);

Thanks for the idea. :)
argv
 
Joined: 30 Aug 2016

Previous

Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests