File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,11 @@ runtimeFunctions.retire = `const retire = () => {
223223 thread.target.runtime.sequencer.retireThread(thread);
224224}` ;
225225
226+ runtimeFunctions . NaNToZero = `const NaNToZero = value => {
227+ if (isNaN(value)) return 0;
228+ return value;
229+ }` ;
230+
226231/**
227232 * Scratch cast to boolean.
228233 * Similar to Cast.toBoolean()
Original file line number Diff line number Diff line change @@ -185,9 +185,9 @@ class JSGenerator {
185185 return `(+${ this . descendInput ( node . target . toType ( InputType . BOOLEAN ) ) } )` ;
186186 }
187187 if ( node . target . isAlwaysType ( InputType . NUMBER_OR_NAN ) ) {
188- return `(${ this . descendInput ( node . target ) } || 0 )` ;
188+ return `NaNToZero (${ this . descendInput ( node . target ) } )` ;
189189 }
190- return `(+${ this . descendInput ( node . target ) } || 0 )` ;
190+ return `NaNToZero (+${ this . descendInput ( node . target ) } )` ;
191191 case InputOpcode . CAST_NUMBER_OR_NAN :
192192 return `(+${ this . descendInput ( node . target ) } )` ;
193193 case InputOpcode . CAST_NUMBER_INDEX :
You can’t perform that action at this time.
0 commit comments