.constant() Converts a given number into an object that tries to express the number using e, pi, or as a fraction. For comparison, use +fraction === myNum i.e. (+constant(4)) === 4 is true ( constant(4)) === 4 is false
164643
function () {
            var f = {};

            f.valueOf = function () {
                return +n;
            };

            f.text = String(goodFrac(n) || n);

            return f;
        }
248481
function BigNumber( n, b ) {
            var c, e, i, num, len, str,
                x = this;

            // Enable constructor usage without new.
            if ( !( x instanceof BigNumber ) ) {

                // 'BigNumber() constructor call without new: {n}'
                if (ERRORS) raise( 26, 'constructor call without new', n );
                return new BigNumber( n, b );
            }

            // 'new BigNumber() base not an integer: {b}'
            // 'new BigNumber() base out of range: {b}'
            if ( b == null || !isValidInt( b, 2, 64, id, 'base' ) ) {

                // Duplicate.
                if ( n instanceof BigNumber ) {
                    x.s = n.s;
                    x.e = n.e;
                    x.c = ( n = n.c ) ? n.slice() : n;
                    id = 0;
                    return;
                }

                if ( ( num = typeof n == 'number' ) && n * 0 == 0 ) {
                    x.s = 1 / n < 0 ? ( n = -n, -1 ) : 1;

                    // Fast path for integers.
                    if ( n === ~~n ) {
                        for ( e = 0, i = n; i >= 10; i /= 10, e++ );
                        x.e = e;
                        x.c = [n];
                        id = 0;
                        return;
                    }

                    str = n + '';
                } else {
                    if ( !isNumeric.test( str = n + '' ) ) return parseNumeric( x, str, num );
                    x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
                }
            } else {
                b = b | 0;
                str = n + '';

                // Ensure return value is rounded to DECIMAL_PLACES as with other bases.
                // Allow exponential notation to be used with base 10 argument.
                if ( b == 10 ) {
                    x = new BigNumber( n instanceof BigNumber ? n : str );
                    return round( x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE );
                }

                // Avoid potential interpretation of Infinity and NaN as base 44+ values.
                // Any number in exponential form will fail due to the [Ee][+-].
                if ( ( num = typeof n == 'number' ) && n * 0 != 0 ||
                  !( new RegExp( '^-?' + ( c = '[' + ALPHABET.slice( 0, b ) + ']+' ) +
                    '(?:\\.' + c + ')?$',b < 37 ? 'i' : '' ) ).test(str) ) {
                    return parseNumeric( x, str, num, b );
                }

                if (num) {
                    x.s = 1 / n < 0 ? ( str = str.slice(1), -1 ) : 1;

                    if ( ERRORS && str.replace( /^0\.0*|\./, '' ).length > 15 ) {

                        // 'new BigNumber() number type has more than 15 significant digits: {n}'
                        raise( id, tooManyDigits, n );
                    }

                    // Prevent later check for length on converted number.
                    num = false;
                } else {
                    x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
                }

                str = convertBase( str, 10, b, x.s );
            }

            // Decimal point?
            if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );

            // Exponential form?
            if ( ( i = str.search( /e/i ) ) > 0 ) {

                // Determine exponent.
                if ( e < 0 ) e = i;
                e += +str.slice( i + 1 );
                str = str.substring( 0, i );
            } else if ( e < 0 ) {

                // Integer.
                e = str.length;
            }

            // Determine leading zeros.
            for ( i = 0; str.charCodeAt(i) === 48; i++ );

            // Determine trailing zeros.
            for ( len = str.length; str.charCodeAt(--len) === 48; );
            str = str.slice( i, len + 1 );

            if (str) {
                len = str.length;

                // Disallow numbers with over 15 significant digits if number type.
                // 'new BigNumber() number type has more than 15 significant digits: {n}'
                if ( num && ERRORS && len > 15 && ( n > MAX_SAFE_INTEGER || n !== mathfloor(n) ) ) {
                    raise( id, tooManyDigits, x.s * n );
                }

                e = e - i - 1;

                 // Overflow?
                if ( e > MAX_EXP ) {

                    // Infinity.
                    x.c = x.e = null;

                // Underflow?
                } else if ( e < MIN_EXP ) {

                    // Zero.
                    x.c = [ x.e = 0 ];
                } else {
                    x.e = e;
                    x.c = [];

                    // Transform base

                    // e is the base 10 exponent.
                    // i is where to slice str to get the first element of the coefficient array.
                    i = ( e + 1 ) % LOG_BASE;
                    if ( e < 0 ) i += LOG_BASE;

                    if ( i < len ) {
                        if (i) x.c.push( +str.slice( 0, i ) );

                        for ( len -= LOG_BASE; i < len; ) {
                            x.c.push( +str.slice( i, i += LOG_BASE ) );
                        }

                        str = str.slice(i);
                        i = LOG_BASE - str.length;
                    } else {
                        i -= len;
                    }

                    for ( ; i--; str += '0' );
                    x.c.push( +str );
                }
            } else {

                // Zero.
                x.c = [ x.e = 0 ];
            }

            id = 0;
        }
230741
public final void constantExpression() throws RecognitionException {
		int constantExpression_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 107) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1115:5: ( expression )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1115:7: expression
			{
			pushFollow(FOLLOW_expression_in_constantExpression4858);
			expression();
			state._fsp--;
			if (state.failed) return;
			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 107, constantExpression_StartIndex); }

		}
	}
304076
private boolean isIntegerConstant(String columnOrConstant) {
        try {
            Integer.parseInt(columnOrConstant.trim());
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }
841719
function parse(number) {
    const pattern = /([0-9]+)\.([0-9]*[1-9])(e[+-][1-9][0-9]*)?/;
    const matches = number.toString().match(pattern);
    var coefficient = matches[1];
    const decimal = matches[2];
    const exponent = matches[3] ? Number(matches[3].slice(1)) : 0;
    if (coefficient === '0') coefficient = '';  // leading zero does not count
    return {
        coefficient: coefficient,
        decimal: decimal,
        exponent: exponent
    };
}
515509
function getDecimal(value) {
    if (!value) {
        return 0;
    }

    var num = value;
    if (!_.isNumber(value)) {
        var isNeg = ('-' && _.includes(value, '-'));

        var regExp = '[^0-9.]';
        var numString = value.toString().replace(new RegExp(regExp, 'g'), '');

        var numList = numString.split('.');

        // numList will always have at least one value in array because we checked for an empty string earlier.
        numList[0] += '.';
        numString = numList.join('');
        num = parseFloat(numString);

        if (!num) {
            num = 0;
        } else if (isNeg) {
            num *= -1;
        }
    }

    return num;
}
907278
def fmt_number(p):
    
    formatted = '{:n}'.format(p)

    if not config.PRINT_FRACTIONS:
        return formatted

    fraction = Fraction(p)
    nice = fraction.limit_denominator(128)
    return (
        str(nice) if (abs(fraction - nice) < constants.EPSILON and
                      nice.denominator in NICE_DENOMINATORS)
        else formatted
    )
55084
function (valueString) {
			// TODO: Detect other number formats (e.g. comma as decimal separator)
			var valueComp = valueString.split('.');
			var integralPart = valueComp[0];
			var fractionalPart = valueComp[1] || "0";
			while (fractionalPart.length < 8) fractionalPart += "0";
			fractionalPart = fractionalPart.replace(/^0+/g, '');
			var value = BigInteger.valueOf(parseInt(integralPart));
			value = value.multiply(BigInteger.valueOf(100000000));
			value = value.add(BigInteger.valueOf(parseInt(fractionalPart)));
			return value;
		}
824381
private static Object coerceNumber(Object value) {
            if ( value instanceof Number && !(value instanceof BigDecimal) ) {
                return getBigDecimalOrNull( value );
            } else {
                return value;
            }
        }
73413
static Number coerceToPrimitiveNumber(String pValue,
                                          Class pClass)
            throws ELException {
        if (pClass == Byte.class || pClass == Byte.TYPE) {
            return Byte.valueOf(pValue);
        } else if (pClass == Short.class || pClass == Short.TYPE) {
            return Short.valueOf(pValue);
        } else if (pClass == Integer.class || pClass == Integer.TYPE) {
            return Integer.valueOf(pValue);
        } else if (pClass == Long.class || pClass == Long.TYPE) {
            return Long.valueOf(pValue);
        } else if (pClass == Float.class || pClass == Float.TYPE) {
            return Float.valueOf(pValue);
        } else if (pClass == Double.class || pClass == Double.TYPE) {
            return Double.valueOf(pValue);
        } else {
            return PrimitiveObjects.getInteger(0);
        }
    }
262660
private static Number asNumber(Object value) {
    Number num = null;
    if (value == null) {
      num = null;
    } else if (value instanceof Number) {
      num = (Number) value;
    } else if (value instanceof Boolean) {
      num = ((Boolean) value) ? 1 : 0;
    }
    return num;
  }
309785
function isSafePositiveInteger(x) {
  // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
  const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
  // Is it a number?
  return Object.prototype.toString.call(x) === '[object Number]' &&
    // Is it an integer?
    x % 1 === 0 &&
    // Is it positive?
    x > 0 &&
    // Is it less than the maximum safe integer?
    x <= MAX_SAFE_INTEGER;
}
335915
function (value) {
        let val = parseInt(value, 10);
        if (isNaN(val)) {
            return false;
        }
        return (val + '').length === value.length;
    }
1309676
public static Integer toInteger(Object v) {
        if (v == null) {
            return null;
        }
        if (v instanceof Boolean) {
            return ((Boolean) v) ? 1 : 0;
        }
        return ((Number) v).intValue();
    }
982367
public static Integer getInteger(Object object) {
        try {
            if(object instanceof Integer)
                return (Integer) object;

            if(object instanceof String)
                return Integer.valueOf((String) object);
        } catch(NumberFormatException  nfe) {
        }
        return null;
    }
1182363
static Number coerceToPrimitiveNumber(long pValue,
                                          Class pClass)
            throws ELException {
        if (pClass == Byte.class || pClass == Byte.TYPE) {
            return PrimitiveObjects.getByte((byte) pValue);
        } else if (pClass == Short.class || pClass == Short.TYPE) {
            return PrimitiveObjects.getShort((short) pValue);
        } else if (pClass == Integer.class || pClass == Integer.TYPE) {
            return PrimitiveObjects.getInteger((int) pValue);
        } else if (pClass == Long.class || pClass == Long.TYPE) {
            return PrimitiveObjects.getLong((long) pValue);
        } else if (pClass == Float.class || pClass == Float.TYPE) {
            return PrimitiveObjects.getFloat((float) pValue);
        } else if (pClass == Double.class || pClass == Double.TYPE) {
            return PrimitiveObjects.getDouble((double) pValue);
        } else {
            return PrimitiveObjects.getInteger(0);
        }
    }
488056
function Fraction(n, d) {
	if(typeof(d) === "number") {
		this.denominator = d;
	} else {
		this.denominator = 1;
	}
	if(typeof(n) === "number") {
		this.numerator = n;
	} else if(typeof(n) === "string") {
		let slash = n.indexOf('/');
		if(slash > 0) {
			/**
			 *	The numerator of the fraction.
			 *
			 *	@type {number}
			 */
			this.numerator = Number.parseInt(n.substring(0, slash));
			/**
			 *	The denominator of the fraction.
			 *
			 *	@type {number}
			 *	@defaultvalue 1
			 */
			this.denominator = Number.parseInt(n.substring(slash + 1));
		} else {
			this.numerator = Number.parseFloat(n);
		}
	} else if((typeof(n) === "object") && (n instanceof Fraction)) {
		this.numerator = n.numerator;
		this.denominator = n.denominator;
	} else {
		throw new TypeError(`${n} must be a number or a string`);
	}
	/**
	 *	The numeric value of the fraction i.e., numerator divided by denominator.
	 *
	 *	@type {number}
	 */
	this.value = this.numerator / this.denominator;
}