This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function NORMDIST(x, mean, sd, cumulative) { | |
// Check parameters | |
if (isNaN(x) || isNaN(mean) || isNaN(sd)) return '#VALUE!'; | |
if (sd <= 0) return '#NUM!'; | |
// Return normal distribution computed by jStat [http://jstat.org] | |
return (cumulative) ? jStat.normal.cdf(x, mean, sd) : jStat.normal.pdf(x, mean, sd); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function BIN2HEX(number, places) { | |
// Return error if number is not binary or contains more than 10 characters (10 digits) | |
if (!/^[01]{1,10}$/.test(number)) return '#NUM!'; | |
// Ignore places and return a 10-character hexadecimal number if number is negative | |
var stringified = number.toString(); | |
if (stringified.length === 10 && stringified.substring(0, 1) === '1') { | |
return (1099511627264 + parseInt(stringified.substring(1), 2)).toString(16); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function BIN2DEC(number) { | |
// Return error if number is not binary or contains more than 10 characters (10 digits) | |
if (!/^[01]{1,10}$/.test(number)) return '#NUM!'; | |
// Convert binary number to decimal | |
var result = parseInt(number, 2); | |
// Handle negative numbers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function BIN2OCT(number, places) { | |
// Return error if number is not binary or contains more than 10 characters (10 digits) | |
if (!/^[01]{1,10}$/.test(number)) return '#NUM!'; | |
// Ignore places and return a 10-character octal number if number is negative | |
var stringified = number.toString(); | |
if (stringified.length === 10 && stringified.substring(0, 1) === '1') { | |
return (1073741312 + parseInt(stringified.substring(1), 2)).toString(8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function DEC2HEX(number, places) { | |
// Return error if number is not a number | |
if (isNaN(number)) return '#VALUE!'; | |
// Return error if number is not decimal, is lower than -549755813888, or is greater than 549755813887 | |
if (!/^-?[0-9]{1,12}$/.test(number) || number < -549755813888 || number > 549755813887) return '#NUM!'; | |
// Ignore places and return a 10-character hexadecimal number if number is negative |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function BITAND(number1, number2) { | |
// Return error if either number is a non-numeric value | |
if (isNaN(number1) || isNaN(number2)) return '#VALUE!'; | |
// Return error if either number is less than 0 | |
if (number1 < 0 || number2 < 0) return '#NUM!'; | |
// Return error if either number is a non-integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function BITOR(number1, number2) { | |
// Return error if either number is a non-numeric value | |
if (isNaN(number1) || isNaN(number2)) return '#VALUE!'; | |
// Return error if either number is less than 0 | |
if (number1 < 0 || number2 < 0) return '#NUM!'; | |
// Return error if either number is a non-integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function BITXOR(number1, number2) { | |
// Return error if either number is a non-numeric value | |
if (isNaN(number1) || isNaN(number2)) return '#VALUE!'; | |
// Return error if either number is less than 0 | |
if (number1 < 0 || number2 < 0) return '#NUM!'; | |
// Return error if either number is a non-integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function BITLSHIFT(number, shift) { | |
// Return error if either number is a non-numeric value | |
if (isNaN(number) || isNaN(shift)) return '#VALUE!'; | |
// Return error if number is less than 0 | |
if (number < 0) return '#NUM!'; | |
// Return error if number is a non-integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function BITRSHIFT(number, shift) { | |
// Return error if either number is a non-numeric value | |
if (isNaN(number) || isNaN(shift)) return '#VALUE!'; | |
// Return error if number is less than 0 | |
if (number < 0) return '#NUM!'; | |
// Return error if number is a non-integer |
OlderNewer