Apply spell check (#41)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// CalcErr.h
|
||||
@@ -6,7 +6,7 @@
|
||||
// Defines the error codes thrown by ratpak and caught by Calculator
|
||||
//
|
||||
//
|
||||
// Ratpak errors are 32 bit values layed out as follows:
|
||||
// Ratpak errors are 32 bit values laid out as follows:
|
||||
//
|
||||
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
|
||||
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
||||
@@ -31,8 +31,8 @@
|
||||
//
|
||||
// Code - is the actual error code
|
||||
//
|
||||
// This format is based losely on an OLE HRESULT and is compatible with the
|
||||
// SUCCEEDED and FAILED marcos as well as the HRESULT_CODE macro
|
||||
// This format is based loosely on an OLE HRESULT and is compatible with the
|
||||
// SUCCEEDED and FAILED macros as well as the HRESULT_CODE macro
|
||||
|
||||
// CALC_E_DIVIDEBYZERO
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -42,7 +42,7 @@ void __inline mulnumx( PNUMBER *pa, PNUMBER b )
|
||||
// If b is not one we multiply
|
||||
if ( (*pa)->cdigit > 1 || (*pa)->mant[0] != 1 || (*pa)->exp != 0 )
|
||||
{
|
||||
// pa and b are both nonone.
|
||||
// pa and b are both non-one.
|
||||
_mulnumx( pa, b );
|
||||
}
|
||||
else
|
||||
@@ -71,7 +71,7 @@ void __inline mulnumx( PNUMBER *pa, PNUMBER b )
|
||||
//
|
||||
// DESCRIPTION: Does the number equivalent of *pa *= b.
|
||||
// Assumes the base is BASEX of both numbers. This algorithm is the
|
||||
// same one you learned in gradeschool, except the base isn't 10 it's
|
||||
// same one you learned in grade school, except the base isn't 10 it's
|
||||
// BASEX.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -148,7 +148,7 @@ void _mulnumx( PNUMBER *pa, PNUMBER b )
|
||||
}
|
||||
}
|
||||
|
||||
// prevent different kinds of zeros, by stripping leading duplicate zeroes.
|
||||
// prevent different kinds of zeros, by stripping leading duplicate zeros.
|
||||
// digits are in order of increasing significance.
|
||||
while ( c->cdigit > 1 && c->mant[c->cdigit-1] == 0 )
|
||||
{
|
||||
@@ -342,7 +342,7 @@ void _divnumx( PNUMBER *pa, PNUMBER b, int32_t precision)
|
||||
|
||||
if ( !cdigits )
|
||||
{
|
||||
// A zero, make sure no wierd exponents creep in
|
||||
// A zero, make sure no weird exponents creep in
|
||||
c->exp = 0;
|
||||
c->cdigit = 1;
|
||||
}
|
||||
@@ -351,7 +351,7 @@ void _divnumx( PNUMBER *pa, PNUMBER b, int32_t precision)
|
||||
c->cdigit = cdigits;
|
||||
c->exp -= cdigits;
|
||||
// prevent different kinds of zeros, by stripping leading duplicate
|
||||
// zeroes. digits are in order of increasing significance.
|
||||
// zeros. digits are in order of increasing significance.
|
||||
while ( c->cdigit > 1 && c->mant[c->cdigit-1] == 0 )
|
||||
{
|
||||
c->cdigit--;
|
||||
|
@@ -33,7 +33,7 @@ long g_ratio; // int(log(2L^BASEXPWR)/log(radix))
|
||||
// Default decimal separator
|
||||
wchar_t g_decimalSeparator = L'.';
|
||||
|
||||
// Used to strip trailing zeroes, and prevent combinatorial explosions
|
||||
// Used to strip trailing zeros, and prevent combinatorial explosions
|
||||
bool stripzeroesnum(_Inout_ PNUMBER pnum, long starting);
|
||||
|
||||
void SetDecimalSeparator(wchar_t decimalSeparator)
|
||||
@@ -121,7 +121,7 @@ void _destroyrat( _In_ PRAT prat )
|
||||
//
|
||||
// RETURN: pointer to a number
|
||||
//
|
||||
// DESCRIPTION: allocates and zeroes out number type.
|
||||
// DESCRIPTION: allocates and zeros out number type.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -480,7 +480,7 @@ PRAT StringToRat(bool mantissaIsNegative, wstring_view mantissa, bool exponentIs
|
||||
// ZR '0'
|
||||
// NZ '1'..'9' 'A'..'Z' 'a'..'z' '@' '_'
|
||||
// SG '+' '-'
|
||||
// EX 'e' '^' e is used for radix 10, ^ for all other radixs.
|
||||
// EX 'e' '^' e is used for radix 10, ^ for all other radixes.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
static constexpr uint8_t DP = 0;
|
||||
@@ -911,8 +911,8 @@ unsigned long rattoUlong( _In_ PRAT prat, uint32_t radix, int32_t precision)
|
||||
// DESCRIPTION: returns the 64 bit (irrespective of which processor this is running in) representation of the
|
||||
// number input. Assumes that the number is in the internal
|
||||
// base. Can throw exception if the number exceeds 2^64
|
||||
// Implementation by getting the HI & LO 32 bit words and concating them, as the
|
||||
// internal base choosen happens to be 2^32, this is easier.
|
||||
// Implementation by getting the HI & LO 32 bit words and concatenating them, as the
|
||||
// internal base chosen happens to be 2^32, this is easier.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ULONGLONG rattoUlonglong( _In_ PRAT prat, uint32_t radix, int32_t precision)
|
||||
@@ -981,7 +981,7 @@ long numtolong( _In_ PNUMBER pnum, uint32_t radix )
|
||||
//
|
||||
// RETURN: true if stripping done, modifies number in place.
|
||||
//
|
||||
// DESCRIPTION: Strips off trailing zeroes.
|
||||
// DESCRIPTION: Strips off trailing zeros.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -1001,7 +1001,7 @@ bool stripzeroesnum(_Inout_ PNUMBER pnum, long starting)
|
||||
cdigits = starting;
|
||||
}
|
||||
|
||||
// Check we haven't gone too far, and we are still looking at zeroes.
|
||||
// Check we haven't gone too far, and we are still looking at zeros.
|
||||
while ( ( cdigits > 0 ) && !(*pmant) )
|
||||
{
|
||||
// move to next significant digit and keep track of digits we can
|
||||
@@ -1011,7 +1011,7 @@ bool stripzeroesnum(_Inout_ PNUMBER pnum, long starting)
|
||||
fstrip = true;
|
||||
}
|
||||
|
||||
// If there are zeroes to remove.
|
||||
// If there are zeros to remove.
|
||||
if ( fstrip )
|
||||
{
|
||||
// Remove them.
|
||||
@@ -1061,7 +1061,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
|
||||
// 10 for maximum exponent size.
|
||||
int cchNum = (precision + 16);
|
||||
|
||||
// If there is a chance a round has to occour, round.
|
||||
// If there is a chance a round has to occur, round.
|
||||
// - if number is zero no rounding
|
||||
// - if number of digits is less than the maximum output no rounding
|
||||
PNUMBER round = nullptr;
|
||||
@@ -1087,7 +1087,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
|
||||
|
||||
if (format == FMT_FLOAT)
|
||||
{
|
||||
// Figure out if the exponent will fill more space than the nonexponent field.
|
||||
// Figure out if the exponent will fill more space than the non-exponent field.
|
||||
if ((length - exponent > precision) || (exponent > precision + 3))
|
||||
{
|
||||
if (exponent >= -MAX_ZEROS_AFTER_DECIMAL)
|
||||
@@ -1097,15 +1097,15 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case where too many zeroes are to the right or left of the
|
||||
// Case where too many zeros are to the right or left of the
|
||||
// decimal pt. And we are forced to switch to scientific form.
|
||||
format = FMT_SCIENTIFIC;
|
||||
}
|
||||
}
|
||||
else if (length + abs(exponent) < precision && round)
|
||||
{
|
||||
// Minimum loss of precision occours with listing leading zeros
|
||||
// if we need to make room for zeroes sacrifice some digits.
|
||||
// Minimum loss of precision occurs with listing leading zeros
|
||||
// if we need to make room for zeros sacrifice some digits.
|
||||
round->exp -= exponent;
|
||||
}
|
||||
}
|
||||
@@ -1118,7 +1118,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
|
||||
if (stripzeroesnum(pnum, offset))
|
||||
{
|
||||
// WARNING: nesting/recursion, too much has been changed, need to
|
||||
// refigure format.
|
||||
// re-figure format.
|
||||
return NumberToString(pnum, oldFormat, radix, precision);
|
||||
}
|
||||
}
|
||||
@@ -1165,7 +1165,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
|
||||
// Begin building the result string
|
||||
wstringstream resultStream{};
|
||||
|
||||
// Make sure negative zeroes aren't allowed.
|
||||
// Make sure negative zeros aren't allowed.
|
||||
if ((pnum->sign == -1) && (length > 0))
|
||||
{
|
||||
resultStream << L'-';
|
||||
@@ -1399,7 +1399,7 @@ PNUMBER longfactnum(long inlong, uint32_t radix)
|
||||
// ARGUMENTS:
|
||||
// long integer to factorialize.
|
||||
// long integer representing base of answer.
|
||||
// unsignd long integer for radix
|
||||
// unsigned long integer for radix
|
||||
//
|
||||
// RETURN: Factorial of input in base PNUMBER form.
|
||||
//
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -235,7 +235,7 @@ void log10rat( PRAT *px, int32_t precision)
|
||||
}
|
||||
|
||||
//
|
||||
// return if the given x is even number. The assumption here is its numberator is 1 and we are testing the numerator is
|
||||
// return if the given x is even number. The assumption here is its numerator is 1 and we are testing the numerator is
|
||||
// even or not
|
||||
bool IsEven(PRAT x, uint32_t radix, int32_t precision)
|
||||
{
|
||||
@@ -291,7 +291,7 @@ void powrat(PRAT *px, PRAT y, uint32_t radix, int32_t precision)
|
||||
catch (...)
|
||||
{
|
||||
// If calculating the power using numerator/denominator
|
||||
// failed, fallback to the less accurate method of
|
||||
// failed, fall back to the less accurate method of
|
||||
// passing in the original y
|
||||
powratcomp(px, y, radix, precision);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -150,7 +150,7 @@ void _addnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
|
||||
}
|
||||
else
|
||||
{
|
||||
// In this particular case an overflow or underflow has occoured
|
||||
// In this particular case an overflow or underflow has occurred
|
||||
// and all the digits need to be complemented, at one time an
|
||||
// attempt to handle this above was made, it turned out to be much
|
||||
// slower on average.
|
||||
@@ -167,7 +167,7 @@ void _addnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove leading zeroes, remember digits are in order of
|
||||
// Remove leading zeros, remember digits are in order of
|
||||
// increasing significance. i.e. 100 would be 0,0,1
|
||||
while ( c->cdigit > 1 && *(--pchc) == 0 )
|
||||
{
|
||||
@@ -188,7 +188,7 @@ void _addnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
|
||||
//
|
||||
// DESCRIPTION: Does the number equivalent of *pa *= b.
|
||||
// Assumes radix is the radix of both numbers. This algorithm is the
|
||||
// same one you learned in gradeschool.
|
||||
// same one you learned in grade school.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -200,7 +200,7 @@ void __inline mulnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
|
||||
if ( b->cdigit > 1 || b->mant[0] != 1 || b->exp != 0 )
|
||||
{ // If b is one we don't multiply exactly.
|
||||
if ( (*pa)->cdigit > 1 || (*pa)->mant[0] != 1 || (*pa)->exp != 0 )
|
||||
{ // pa and b are both nonone.
|
||||
{ // pa and b are both non-one.
|
||||
_mulnum( pa, b, radix);
|
||||
}
|
||||
else
|
||||
@@ -285,7 +285,7 @@ void _mulnum( PNUMBER *pa, PNUMBER b, uint32_t radix)
|
||||
}
|
||||
}
|
||||
|
||||
// prevent different kinds of zeros, by stripping leading duplicate zeroes.
|
||||
// prevent different kinds of zeros, by stripping leading duplicate zeros.
|
||||
// digits are in order of increasing significance.
|
||||
while ( c->cdigit > 1 && c->mant[c->cdigit-1] == 0 )
|
||||
{
|
||||
|
@@ -237,7 +237,7 @@ void addrat( PRAT *pa, PRAT b, int32_t precision)
|
||||
(*pa)->pq = bot;
|
||||
trimit(pa, precision);
|
||||
|
||||
// Get rid of negative zeroes here.
|
||||
// Get rid of negative zeros here.
|
||||
(*pa)->pp->sign *= (*pa)->pq->sign;
|
||||
(*pa)->pq->sign = 1;
|
||||
}
|
||||
|
@@ -474,7 +474,7 @@ void scale( PRAT *px, PRAT scalefact, uint32_t radix, int32_t precision )
|
||||
DUPRAT(pret,*px);
|
||||
|
||||
// Logscale is a quick way to tell how much extra precision is needed for
|
||||
// scaleing by scalefact.
|
||||
// scaling by scalefact.
|
||||
long logscale = g_ratio * ( (pret->pp->cdigit+pret->pp->exp) -
|
||||
(pret->pq->cdigit+pret->pq->exp) );
|
||||
if ( logscale > 0 )
|
||||
@@ -509,7 +509,7 @@ void scale2pi( PRAT *px, uint32_t radix, int32_t precision )
|
||||
DUPRAT(pret,*px);
|
||||
|
||||
// Logscale is a quick way to tell how much extra precision is needed for
|
||||
// scaleing by 2 pi.
|
||||
// scaling by 2 pi.
|
||||
long logscale = g_ratio * ( (pret->pp->cdigit+pret->pp->exp) -
|
||||
(pret->pq->cdigit+pret->pq->exp) );
|
||||
if ( logscale > 0 )
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -134,7 +134,7 @@ void sinanglerat( _Inout_ PRAT *pa, ANGLE_TYPE angletype, uint32_t radix, int32_
|
||||
//
|
||||
// ARGUMENTS: x PRAT representation of number to take the cosine of
|
||||
//
|
||||
// RETURN: cosin of x in PRAT form.
|
||||
// RETURN: cosine of x in PRAT form.
|
||||
//
|
||||
// EXPLANATION: This uses Taylor series
|
||||
//
|
||||
|
Reference in New Issue
Block a user