Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added 18 mathematical functions ROMAN, ARABIC, FACT, FACTDOUBLE, COMBIN, COMBINA, GCD, LCM, MROUND, MULTINOMIAL, QUOTIENT, RANDBETWEEN, SERIESSUM, SIGN, SQRTPI, SUMX2MY2, SUMX2PY2, SUMXMY2.
- Added 63 statistical functions EXPON.DIST, EXPONDIST, FISHER, FISHERINV, GAMMA, GAMMA.DIST, GAMMADIST, GAMMALN, GAMMALN.PRECISE, GAMMA.INV, GAMMAINV, GAUSS, BETA.DIST, BETADIST, BETA.INV, BETAINV, BINOM.DIST, BINOMDIST, BINOM.INV, BESSELI, BESSELJ, BESSELK, BESSELY, CHISQ.DIST, CHISQ.DIST.RT, CHISQ.INV, CHISQ.INV.RT, CHIDIST, CHIINV, F.DIST, F.DIST.RT, F.INV, F.INV.RT, FDIST, FINV, WEIBULL, WEIBULL.DIST, HYPGEOMDIST, HYPGEOM.DIST, T.DIST, T.DIST.2T, T.DIST.RT, T.INV, T.INV.2T, TDIST, TINV, LOGNORM.DIST, LOGNORMDIST, LOGNORM.INV, LOGINV, NORM.DIST, NORMDIST, NORM.S.DIST, NORMSDIST, NORM.INV, NORMINV, NORM.S.INV, NORMSINV, PHI, NEGBINOM.DIST, NEGBINOMDIST, POISSON, POISSON.DIST.
- Added function aliases mechanism. (#569)
- Added support for scientific notation. (#579)
- Added 26 math functions COMPLEX, IMABS, IMAGINARY, IMARGUMENT, IMCONJUGATE, IMCOS, IMCOSH, IMCOT, IMCSC, IMCSCH, IMDIV, IMEXP, IMLN, IMLOG10, IMLOG2, IMPOWER, IMPRODUCT, IMREAL, IMSEC, IMSECH, IMSIN, IMSINH, IMSQRT, IMSUB, IMSUM, IMTAN.
Comment thread
izulin marked this conversation as resolved.
Resolved

### Fixed
- Fixed a problem with dependencies not collected for specific functions. (#550, #549)
- Fixed a minor problem with dependencies under nested parenthesis. (#549, #558)
- Fixed a problem with HLOOKUP/VLOOKUP getting stuck in binary search. (#559, #562)
- Fixed a problem with logic of dependency resolving. (#561, #563)
- Fixed minor bug with ATAN2 function.
Comment thread
izulin marked this conversation as resolved.
Resolved

## [0.3.0] - 2020-10-22

Expand Down
26 changes: 26 additions & 0 deletions docs/guide/built-in-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ lets you design your own [custom functions](custom-functions).
| BITOR | Engineering | Returns a bitwise logical "or" of the parameters. | BITOR(Number1; Number2) |
| BITRSHIFT | Engineering | Shifts a number right by n bits. | BITRSHIFT(Number; Shift) |
| BITXOR | Engineering | Returns a bitwise logical "exclusive or" of the parameters. | BITXOR(Number1; Number2) |
| COMPLEX | Engineering | Returns complex number from Re and Im parts. | COMPLEX(Re; Im[; Symbol]) |
| DEC2BIN | Engineering | Returns the binary number for the decimal number entered between –512 and 511. | DEC2BIN(Number; Places) |
| DEC2HEX | Engineering | Returns the hexadecimal number for the decimal number entered. | DEC2HEX(Number; Places) |
| DEC2OCT | Engineering | Returns the octal number for the decimal number entered. | DEC2OCT(Number; Places) |
Expand All @@ -104,6 +105,31 @@ lets you design your own [custom functions](custom-functions).
| HEX2BIN <br><Badge text="v0.2.0"/>| Engineering | The result is the binary number for the hexadecimal number entered. | HEX2BIN(Number; Places) |
| HEX2DEC <br><Badge text="v0.2.0"/>| Engineering | The result is the decimal number for the hexadecimal number entered. | HEX2DEC(Number) |
| HEX2OCT <br><Badge text="v0.2.0"/>| Engineering | The result is the octal number for the hexadecimal number entered. | HEX2OCT(Number; Places) |
| IMABS | Engineering | Returns module of a complex number. | IMABS(Complex) |
| IMAGINARY | Engineering | Returns imaginary part of a complex number. | IMAGINARY(Complex) |
| IMARGUMENT | Engineering | Returns argument of a complex number. | IMARGUMENT(Complex) |
| IMCONJUGATE | Engineering | Returns conjugate of a complex number. | IMCONJUGATE(Complex) |
| IMCOS | Engineering | Returns cosine of a complex number. | IMCOS(Complex) |
| IMCOSH | Engineering | Returns hyperbolic cosine of a complex number. | IMCOSH(Complex) |
| IMCOT | Engineering | Returns cotangens of a complex number. | IMCOT(Complex) |
| IMCSC | Engineering | Returns cosecans of a complex number. | IMCSC(Complex) |
| IMCSCH | Engineering | Returns hyperbolic cosecans of a complex number. | IMCSCH(Complex) |
| IMDIV | Engineering | Divides two complex numbers. | IMDIV(Complex1; Complex2) |
| IMEXP | Engineering | Returns exponent of a complex number. | IMEXP(Complex) |
| IMLN | Engineering | Returns natural logarithm of a complex number. | IMLN(Complex) |
| IMLOG2 | Engineering | Returns binary logarithm of a complex number. | IMLOG2(Complex) |
| IMLOG10 | Engineering | Returns base-10 logarithm of a complex number. | IMLOG10(Complex) |
| IMPOWER | Engineering | Returns a complex number raised to a given power. | IMPOWER(Complex; Number) |
| IMPRODUCT | Engineering | Multiplies complex numbers. | IMPRODUCT(Complex1 ...Complex30) |
| IMREAL | Engineering | Returns real part of a complex number. | IMREAL(Complex) |
| IMSEC | Engineering | Returns secans of a complex number. | IMSEC(Complex) |
| IMSECH | Engineering | Returns hyperbolic secans of a complex number. | IMSECH(Complex) |
| IMSIN | Engineering | Returns sine of a complex number. | IMSIN(Complex) |
| IMSINH | Engineering | Returns hyperbolic sine of a complex number. | IMSINH(Complex) |
| IMSQRT | Engineering | Returns a square root of a complex number. | IMSQRT(Complex) |
| IMSUB | Engineering | Subtracts two complex numbers. | IMSUB(Complex1; Complex2) |
| IMSUM | Engineering | Adds complex numbers. | IMSUM(Complex1 ...Complex30) |
| IMTAN | Engineering | Returns tangens of a complex number. | IMTAN(Complex) |
| OCT2BIN <br><Badge text="v0.2.0"/>| Engineering | The result is the binary number for the octal number entered. | OCT2BIN(Number; Places) |
| OCT2DEC <br><Badge text="v0.2.0"/>| Engineering | The result is the decimal number for the octal number entered. | OCT2DEC(Number) |
| OCT2HEX <br><Badge text="v0.2.0"/>| Engineering | The result is the hexadecimal number for the octal number entered. | OCT2HEX(Number; Places) |
Expand Down
5 changes: 3 additions & 2 deletions src/CellContentParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ export class CellContentParser {
return new CellContent.Error(this.config.errorMapping[content.toUpperCase()])
} else {
const trimmedContent = content.trim()
if (this.numberLiteralsHelper.isNumber(trimmedContent)) {
return new CellContent.Number(this.numberLiteralsHelper.numericStringToNumber(trimmedContent))
const parseAsNum = this.numberLiteralsHelper.numericStringToMaybeNumber(trimmedContent)
if(parseAsNum !== undefined) {
return new CellContent.Number(parseAsNum)
}
const parsedDateNumber = this.dateHelper.dateStringToDateNumber(trimmedContent)
if (parsedDateNumber !== undefined) {
Expand Down
22 changes: 18 additions & 4 deletions src/NumberLiteralHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import {Config} from './Config'
import {Maybe} from './Maybe'

export class NumberLiteralHelper {
private readonly numberPattern: RegExp
Expand All @@ -15,13 +16,26 @@ export class NumberLiteralHelper {
const thousandSeparator = this.config.thousandSeparator === '.' ? `\\${this.config.thousandSeparator}` : this.config.thousandSeparator
const decimalSeparator = this.config.decimalSeparator === '.' ? `\\${this.config.decimalSeparator}` : this.config.decimalSeparator

this.numberPattern = new RegExp(`^([+-]?((${decimalSeparator}\\d+)|(\\d+(${thousandSeparator}\\d{3,})*(${decimalSeparator}\\d+)?)))$`)
this.numberPattern = new RegExp(`^([+-]?((${decimalSeparator}\\d+)|(\\d+(${thousandSeparator}\\d{3,})*(${decimalSeparator}\\d*)?)))(e[+-]?\\d+)?$`)
this.allThousandSeparatorsRegex = new RegExp(`${thousandSeparator}`, 'g')
}


public numericStringToMaybeNumber(input: string): Maybe<number> {
if(this.numberPattern.test(input)) {
const num = this.numericStringToNumber(input)
if(isNaN(num)) {
return undefined
}
return num
}
return undefined
}

public isNumber(input: string): boolean {
const match = this.numberPattern.test(input)
return match
if (this.numberPattern.test(input)) {
return !isNaN(this.numericStringToNumber(input))
}
return false
}

public numericStringToNumber(input: string): number {
Expand Down
2 changes: 2 additions & 0 deletions src/error-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export class ErrorMessage {
public static WeekendString = 'Incorrect weekend bitmask string.'
public static InvalidRoman = 'Invalid roman numeral.'
public static WrongOrder = 'Wrong order of values.'
public static ComplexNumberExpected = 'Complex number expected.'
public static ShouldBeIorJ = 'Should be \'i\' or \'j\'.'
public static FunctionName = (arg: string) => `Function name ${arg} not recognized.`
public static NamedExpressionName = (arg: string) => `Named expression ${arg} not recognized.`
public static LicenseKey = (arg: string) => `License key is ${arg}.`
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/languages/csCZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,32 @@ const dictionary: RawTranslationPackage = {
PHI: 'PHI',
'NEGBINOM.DIST': 'NEGBINOM.DIST',
NEGBINOMDIST: 'NEGBINOMDIST',
COMPLEX: 'COMPLEX',
IMABS: 'IMABS',
IMAGINARY: 'IMAGINARY',
IMARGUMENT: 'IMARGUMENT',
IMCONJUGATE: 'IMCONJUGATE',
IMCOS: 'IMCOS',
IMCOSH: 'IMCOSH',
IMCOT: 'IMCOT',
IMCSC: 'IMCSC',
IMCSCH: 'IMCSCH',
IMDIV: 'IMDIV',
IMEXP: 'IMEXP',
IMLN: 'IMLN',
IMLOG10: 'IMLOG10',
IMLOG2: 'IMLOG2',
IMPOWER: 'IMPOWER',
IMPRODUCT: 'IMPRODUCT',
IMREAL: 'IMREAL',
IMSEC: 'IMSEC',
IMSECH: 'IMSECH',
IMSIN: 'IMSIN',
IMSINH: 'IMSINH',
IMSQRT: 'IMSQRT',
IMSUB: 'IMSUB',
IMSUM: 'IMSUM',
IMTAN: 'IMTAN',
},
langCode: 'csCZ',
ui: {
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/languages/daDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,32 @@ const dictionary: RawTranslationPackage = {
PHI: 'PHI',
'NEGBINOM.DIST': 'NEGBINOM.FORDELING',
NEGBINOMDIST: 'NEGBINOMFORDELING',
COMPLEX: 'KOMPLEKS',
IMABS: 'IMAGABS',
IMAGINARY: 'IMAGINÆR',
IMARGUMENT: 'IMAGARGUMENT',
IMCONJUGATE: 'IMAGKONJUGERE',
IMCOS: 'IMAGCOS',
IMCOSH: 'IMAGCOSH',
IMCOT: 'IMAGCOT',
IMCSC: 'IMAGCSC',
IMCSCH: 'IMAGCSCH',
IMDIV: 'IMAGDIV',
IMEXP: 'IMAGEKSP',
IMLN: 'IMAGLN',
IMLOG10: 'IMAGLOG10',
IMLOG2: 'IMAGLOG2',
IMPOWER: 'IMAGPOTENS',
IMPRODUCT: 'IMAGPRODUKT',
IMREAL: 'IMAGREELT',
IMSEC: 'IMAGSEC',
IMSIN: 'IMAGSIN',
IMSECH: 'IMAGSECH',
IMSINH: 'IMAGSINH',
IMSQRT: 'IMAGKVROD',
Comment thread
wojciechczerniak marked this conversation as resolved.
Resolved
IMSUB: 'IMAGSUB',
IMSUM: 'IMAGSUM',
IMTAN: 'IMAGTAN',
},
langCode: 'daDK',
ui: {
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/languages/deDE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,32 @@ const dictionary: RawTranslationPackage = {
PHI: 'PHI',
'NEGBINOM.DIST': 'NEGBINOM.VERT',
NEGBINOMDIST: 'NEGBINOMVERT',
COMPLEX: 'KOMPLEXE',
IMABS: 'IMABS',
IMAGINARY: 'IMAGINÄRTEIL',
IMARGUMENT: 'IMARGUMENT',
IMCONJUGATE: 'IMKONJUGIERTE',
IMCOS: 'IMCOS',
IMCOSH: 'IMACOSHYP',
IMCOT: 'IMACOT',
IMCSC: 'IMACOSEC',
IMCSCH: 'IMACOSECHYP',
IMDIV: 'IMDIV',
IMEXP: 'IMEXP',
IMLN: 'IMLN',
IMLOG10: 'IMLOG10',
IMLOG2: 'IMLOG2',
IMPOWER: 'IMAPOTENZ',
IMPRODUCT: 'IMPRODUKT',
IMREAL: 'IMREALTEIL',
IMSEC: 'IMASEC',
IMSECH: 'IMASECHYP',
IMSIN: 'IMSIN',
IMSINH: 'IMASINHYP',
IMSQRT: 'IMWURZEL',
IMSUB: 'IMSUB',
IMSUM: 'IMSUMME',
IMTAN: 'IMATAN',
},
langCode: 'deDE',
ui: {
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/languages/enGB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,32 @@ const dictionary: RawTranslationPackage = {
PHI: 'PHI',
'NEGBINOM.DIST': 'NEGBINOM.DIST',
'NEGBINOMDIST': 'NEGBINOMDIST',
COMPLEX: 'COMPLEX',
IMABS: 'IMABS',
IMAGINARY: 'IMAGINARY',
IMARGUMENT: 'IMARGUMENT',
IMCONJUGATE: 'IMCONJUGATE',
IMCOS: 'IMCOS',
IMCOSH: 'IMCOSH',
IMCOT: 'IMCOT',
IMCSC: 'IMCSC',
IMCSCH: 'IMCSCH',
IMDIV: 'IMDIV',
IMEXP: 'IMEXP',
IMLN: 'IMLN',
IMLOG10: 'IMLOG10',
IMLOG2: 'IMLOG2',
IMPOWER: 'IMPOWER',
IMPRODUCT: 'IMPRODUCT',
IMREAL: 'IMREAL',
IMSEC: 'IMSEC',
IMSECH: 'IMSECH',
IMSIN: 'IMSIN',
IMSINH: 'IMSINH',
IMSQRT: 'IMSQRT',
IMSUB: 'IMSUB',
IMSUM: 'IMSUM',
IMTAN: 'IMTAN',
},
langCode: 'enGB',
ui: {
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/languages/esES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,32 @@ export const dictionary: RawTranslationPackage = {
PHI: 'PHI',
'NEGBINOM.DIST': 'NEGBINOM.DIST',
NEGBINOMDIST: 'NEGBINOMDIST',
COMPLEX: 'COMPLEJO',
IMABS: 'IM.ABS',
IMAGINARY: 'IMAGINARIO',
IMARGUMENT: 'IM.ANGULO',
IMCONJUGATE: 'IM.CONJUGADA',
IMCOS: 'IM.COS',
IMCOSH: 'IMCOSH',
IMCOT: 'IMCOT',
IMCSC: 'IMCSC',
IMCSCH: 'IMCSCH',
IMDIV: 'IM.DIV',
IMEXP: 'IM.EXP',
IMLN: 'IM.LN',
IMLOG10: 'IM.LOG10',
IMLOG2: 'IM.LOG2',
IMPOWER: 'IM.POT',
IMPRODUCT: 'IM.PRODUCT',
IMREAL: 'IM.REAL',
IMSEC: 'IMSEC',
IMSECH: 'IMSECH',
IMSIN: 'IM.SENO',
IMSINH: 'IMSINH',
IMSQRT: 'IM.RAIZ2',
IMSUB: 'IM.SUSTR',
IMSUM: 'IM.SUM',
IMTAN: 'IMTAN',
},
langCode: 'esES',
ui: {
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/languages/fiFI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,32 @@ const dictionary: RawTranslationPackage = {
PHI: 'FII',
'NEGBINOM.DIST': 'BINOMI.JAKAUMA.NEG',
NEGBINOMDIST: 'BINOMIJAKAUMA.NEG',
COMPLEX: 'KOMPLEKSI',
IMABS: 'KOMPLEKSI.ABS',
IMAGINARY: 'KOMPLEKSI.IMAG',
IMARGUMENT: 'KOMPLEKSI.ARG',
IMCONJUGATE: 'KOMPLEKSI.KONJ',
IMCOS: 'KOMPLEKSI.COS',
IMCOSH: 'KOMPLEKSI.COSH',
IMCOT: 'KOMPLEKSI.COT',
IMCSC: 'KOMPLEKSI.KOSEK',
IMCSCH: 'KOMPLEKSI.KOSEKH',
IMDIV: 'KOMPLEKSI.OSAM',
IMEXP: 'KOMPLEKSI.EKSP',
IMLN: 'KOMPLEKSI.LN',
IMLOG10: 'KOMPLEKSI.LOG10',
IMLOG2: 'KOMPLEKSI.LOG2',
IMPOWER: 'KOMPLEKSI.POT',
IMPRODUCT: 'KOMPLEKSI.TULO',
IMREAL: 'KOMPLEKSI.REAALI',
IMSEC: 'KOMPLEKSI.SEK',
IMSECH: 'KOMPLEKSI.SEKH',
IMSIN: 'KOMPLEKSI.SIN',
IMSINH: 'KOMPLEKSI.SINH',
IMSQRT: 'KOMPLEKSI.NELIÖJ',
IMSUB: 'KOMPLEKSI.EROTUS',
IMSUM: 'KOMPLEKSI.SUM',
IMTAN: 'KOMPLEKSI.TAN',
},
langCode: 'fiFI',
ui: {
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/languages/frFR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,32 @@ const dictionary: RawTranslationPackage = {
PHI: 'PHI',
'NEGBINOM.DIST': 'LOI.BINOMIALE.NEG.N',
NEGBINOMDIST: 'LOI.BINOMIALE.NEG',
COMPLEX: 'COMPLEXE',
IMABS: 'COMPLEXE.MODULE',
IMAGINARY: 'COMPLEXE.IMAGINAIRE',
IMARGUMENT: 'COMPLEXE.ARGUMENT',
IMCONJUGATE: 'COMPLEXE.CONJUGUE',
IMCOS: 'COMPLEXE.COS',
IMCOSH: 'COMPLEXE.COSH',
IMCOT: 'COMPLEXE.COT',
IMCSC: 'COMPLEXE.CSC',
IMCSCH: 'COMPLEXE.CSCH',
IMDIV: 'COMPLEXE.DIV',
IMEXP: 'COMPLEXE.EXP',
IMLN: 'COMPLEXE.LN',
IMLOG10: 'COMPLEXE.LOG10',
IMLOG2: 'COMPLEXE.LOG2',
IMPOWER: 'COMPLEXE.PUISSANCE',
IMPRODUCT: 'COMPLEXE.PRODUIT',
IMREAL: 'COMPLEXE.REEL',
IMSEC: 'COMPLEXE.SEC',
IMSECH: 'COMPLEXE.SECH',
IMSIN: 'COMPLEXE.SIN',
IMSINH: 'COMPLEXE.SINH',
IMSQRT: 'COMPLEXE.RACINE',
IMSUB: 'COMPLEXE.DIFFERENCE',
IMSUM: 'COMPLEXE.SOMME',
IMTAN: 'COMPLEXE.TAN',
},
langCode: 'frFR',
ui: {
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/languages/huHU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,32 @@ const dictionary: RawTranslationPackage = {
PHI: 'FI',
'NEGBINOM.DIST': 'NEGBINOM.ELOSZLÁS',
NEGBINOMDIST: 'NEGBINOM.ELOSZL',
COMPLEX: 'KOMPLEX',
IMABS: 'KÉPZ.ABSZ',
IMAGINARY: 'KÉPZETES',
IMARGUMENT: 'KÉPZ.ARGUMENT',
IMCONJUGATE: 'KÉPZ.KONJUGÁLT',
IMCOS: 'KÉPZ.COS',
IMCOSH: 'KÉPZ.COSH',
IMCOT: 'KÉPZ.COT',
IMCSC: 'KÉPZ.CSC',
IMCSCH: 'KÉPZ.CSCH',
IMDIV: 'KÉPZ.HÁNYAD',
IMEXP: 'KÉPZ.EXP',
IMLN: 'KÉPZ.LN',
IMLOG10: 'KÉPZ.LOG10',
IMLOG2: 'KÉPZ.LOG2',
IMPOWER: 'KÉPZ.HATV',
IMPRODUCT: 'KÉPZ.SZORZAT',
IMREAL: 'KÉPZ.VALÓS',
IMSEC: 'KÉPZ.SEC',
IMSECH: 'KÉPZ.SECH',
IMSIN: 'KÉPZ.SIN',
IMSINH: 'KÉPZ.SINH',
IMSQRT: 'KÉPZ.GYÖK',
IMSUB: 'KÉPZ.KÜL',
IMSUM: 'KÉPZ.ÖSSZEG',
IMTAN: 'KÉPZ.TAN',
},
langCode: 'huHU',
ui: {
Expand Down
Loading