Lines Matching +full:y +full:- +full:max
29 …/* Change this value to change the number of decimal places in the final output - 5 is a good defa…
34 /* 32767 - Might change in the future */
35 MAX = (1 << (SHIFT_AMOUNT - 1)) - 1, enumerator
38 /* -------------------------------------------------------------------------------
39 * NEW TYPE - fINT
40 * -------------------------------------------------------------------------------
51 int real: 32 - SHIFT_AMOUNT;
55 /* -------------------------------------------------------------------------------
57 * -------------------------------------------------------------------------------
64 static fInt fNegate(fInt); /* Returns -1 * input fInt value */
66 static fInt fSubtract (fInt A, fInt B); /* Returns A-B - Sometimes easier than Ad…
83 * -------------------------------------------------------------------------------------
89 /* Internal Support Functions - Use these ONLY for testing or adding to internal functions
90 * -------------------------------------------------------------------------------------
91 …* Some of the following functions take two INTs as their input - This is unsafe for a variety of r…
99 /* -------------------------------------------------------------------------------------
101 * -------------------------------------------------------------------------------------
102 …* 1) ConvertToFraction - InputOutOfRangeException: Only accepts numbers smaller than MAX (default:…
103 * 2) fAdd - OutputOutOfRangeException: Output bigger than MAX (default: 32767)
104 * 3) fMultiply - OutputOutOfRangeException:
105 * 4) fGetSquare - OutputOutOfRangeException:
106 * 5) fDivide - DivideByZeroException
107 * 6) fSqrt - NegativeSquareRootException: Input cannot be a negative number
110 /* -------------------------------------------------------------------------------------
112 * -------------------------------------------------------------------------------------
157 fInt fNegativeOne = ConvertToFraction(-1); in fNaturalLog()
181 fInt f_bit_max_value = Convert_ULONG_ToFraction((uPow(2, bitlength)) - 1); in fDecodeLinearFuse()
196 fInt f_bit_max_value = Convert_ULONG_ToFraction((uPow(2, bitlength)) - 1); in fDecodeLogisticFuse()
198 fInt f_CONSTANT_NEG13 = ConvertToFraction(-13); in fDecodeLogisticFuse()
214 fInt f_bit_max_value = Convert_ULONG_ToFraction((uPow(2, bitlength)) - 1); in fDecodeLeakageID()
228 if (X <= MAX) in ConvertToFraction()
238 fInt CONSTANT_NEGONE = ConvertToFraction(-1); in fNegate()
246 if (X <= MAX) in Convert_ULONG_ToFraction()
265 X = -1*X; in GetScaledFraction()
270 factor = -1*factor; in GetScaledFraction()
274 if ((X > MAX) || factor > MAX) { in GetScaledFraction()
275 if ((X/factor) <= MAX) { in GetScaledFraction()
276 while (X > MAX) { in GetScaledFraction()
281 while (factor > MAX) { in GetScaledFraction()
294 fValue = fDivide(ConvertToFraction(X * uPow(-1, bNEGATED)), ConvertToFraction(factor)); in GetScaledFraction()
303 static fInt fAdd (fInt X, fInt Y) in fAdd() argument
307 Sum.full = X.full + Y.full; in fAdd()
313 static fInt fSubtract (fInt X, fInt Y) in fSubtract() argument
317 Difference.full = X.full - Y.full; in fSubtract()
338 static fInt fMultiply (fInt X, fInt Y) /* Uses 64-bit integers (int64_t) */ in fMultiply() argument
343 /*The following is for a very specific common case: Non-zero number with ONLY fractional portion*/ in fMultiply()
344 /* TEMPORARILY DISABLED - CAN BE USED TO IMPROVE PRECISION in fMultiply()
348 Y_LessThanOne = (Y.partial.real == 0 && Y.partial.decimal != 0 && Y.full >= 0); in fMultiply()
351 Product.full = X.full * Y.full; in fMultiply()
355 …tempProduct = ((int64_t)X.full) * ((int64_t)Y.full); /*Q(16,16)*Q(16,16) = Q(32, 32) - Might becom… in fMultiply()
356 …tempProduct = tempProduct >> 16; /*Remove lagging 16 bits - Will lose some precision from decimal;… in fMultiply()
362 static fInt fDivide (fInt X, fInt Y) in fDivide() argument
369 if (Equal(Y, fZERO)) in fDivide()
373 longlongY = (int64_t)Y.full; in fDivide()
375 longlongX = longlongX << 16; /*Q(16,16) -> Q(32,32) */ in fDivide()
387 scaledReal.full = GetReal(A) * uPow(10, PRECISION-1); /* DOUBLE CHECK THISSSS!!! */ in ConvertBackToInteger()
401 /* x_new = x_old - (x_old^2 - C) / (2 * x_old) */
408 fInt x_new, x_old, C, y; in fSqrt() local
442 y = fSubtract(test, C); /*y = f(x) = x^2 - C; */ in fSqrt()
445 F_divide_Fprime = fDivide(y, Fprime); in fSqrt()
449 error = ConvertBackToInteger(x_new) - ConvertBackToInteger(x_old); in fSqrt()
476 temp = fSubtract(fGetSquare(B), temp); /* root = b^2 - 4AC */ in SolveQuadracticEqn()
477 temp = fSqrt(temp); /*root = Sqrt (b^2 - 4AC); */ in SolveQuadracticEqn()
479 root_first = fSubtract(fNegate(B), temp); /* b - Sqrt(b^2 - 4AC) */ in SolveQuadracticEqn()
480 root_second = fAdd(fNegate(B), temp); /* b + Sqrt(b^2 - 4AC) */ in SolveQuadracticEqn()
482 root_first = fDivide(root_first, ConvertToFraction(2)); /* [b +- Sqrt(b^2 - 4AC)]/[2] */ in SolveQuadracticEqn()
483 root_first = fDivide(root_first, A); /*[b +- Sqrt(b^2 - 4AC)]/[2*A] */ in SolveQuadracticEqn()
485 root_second = fDivide(root_second, ConvertToFraction(2)); /* [b +- Sqrt(b^2 - 4AC)]/[2] */ in SolveQuadracticEqn()
486 root_second = fDivide(root_second, A); /*[b +- Sqrt(b^2 - 4AC)]/[2*A] */ in SolveQuadracticEqn()
492 /* -----------------------------------------------------------------------------
494 * -----------------------------------------------------------------------------
503 static fInt Divide (int X, int Y) in Divide() argument
508 B.full = Y << SHIFT_AMOUNT; in Divide()
515 static int uGetScaledDecimal (fInt A) /*Converts the fractional portion to whole integers - Costly … in uGetScaledDecimal()
522 tmp = tmp - ((1 << SHIFT_AMOUNT)*dec[i]); in uGetScaledDecimal()
524 scaledDecimal = scaledDecimal + dec[i]*uPow(10, PRECISION - 1 - i); in uGetScaledDecimal()
535 return (base)*uPow(base, power - 1); in uPow()
541 return (X * -1); in uAbs()