Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/scratch-vm/src/blocks/scratch3_operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class Scratch3OperatorsBlocks {
case 'floor': return Math.floor(n);
case 'ceiling': return Math.ceil(n);
case 'sqrt': return Math.sqrt(n);
case 'sin': return parseFloat(Math.sin((Math.PI * n) / 180).toFixed(10));
case 'cos': return parseFloat(Math.cos((Math.PI * n) / 180).toFixed(10));
case 'sin': return Math.round(Math.sin((Math.PI * (n % 360)) / 180) * 1e10) / 1e10;
case 'cos': return Math.round(Math.cos((Math.PI * (n % 360)) / 180) * 1e10) / 1e10;
case 'tan': return MathUtil.tan(n);
case 'asin': return (Math.asin(n) * 180) / Math.PI;
case 'acos': return (Math.acos(n) * 180) / Math.PI;
Expand Down
2 changes: 1 addition & 1 deletion packages/scratch-vm/src/util/cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Cast {
return true;
}
// True if it's "round" (e.g., 2.0 and 2).
return val === parseInt(val, 10);
return val % 1 === 0;
} else if (typeof val === 'boolean') {
// `True` and `false` always represent integer after Scratch cast.
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/scratch-vm/src/util/math-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MathUtil {
case 270:
return -Infinity;
default:
return parseFloat(Math.tan((Math.PI * angle) / 180).toFixed(10));
return Math.round(Math.tan((Math.PI * angle) / 180) * 1e10) / 1e10;
}
}

Expand Down
Loading