Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Fix the rounding logic in math.js. Should eliminate wrong answers in …
Browse files Browse the repository at this point in the history
…radians and degrees.
  • Loading branch information
osnr committed May 19, 2011
1 parent 311c90f commit 58b1f2b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jQuery.extend(KhanUtil, {

// Round a number to a certain number of decimal places
roundTo: function( precision, num ) {
var factor = Math.pow( 10, -1 * precision ).toFixed(5);
var factor = Math.pow( 10, precision ).toFixed(5);
return Math.round( ( num * factor ).toFixed(5) ) / factor;
},

Expand Down Expand Up @@ -160,7 +160,7 @@ jQuery.fn.extend({

if ( name ) {
// Show an error if a variable definition is overriding a built-in method
if ( KhanUtil[ name ] || typeof present[ name ] === "function" ) {
if ( KhanUtil[ name ] || ( typeof present !== "undefined" && ( typeof present[ name ] === "function" ) ) ) {
if ( typeof console !== "undefined" ) {
console.error( "Defining variable '" + name + "' overwrites utility property of same name." );
}
Expand Down

0 comments on commit 58b1f2b

Please sign in to comment.