mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-21 22:03:11 -07:00
fixed decimal resetting upon category change
This commit is contained in:
parent
4ffca0cd04
commit
2b3e4f4aad
16 changed files with 48 additions and 51 deletions
|
@ -22,7 +22,7 @@ Calculator ships regularly with new features and bug fixes. You can get the late
|
|||
|
||||
## Getting started
|
||||
Prerequisites:
|
||||
- Your computer must be running Windows 10, version 1809 or newer. Windows 11 is recommended.
|
||||
- Your computer must be running Windows 11, build 22000 or newer.
|
||||
- Install the latest version of [Visual Studio](https://developer.microsoft.com/en-us/windows/downloads) (the free community edition is sufficient).
|
||||
- Install the "Universal Windows Platform Development" workload.
|
||||
- Install the optional "C++ Universal Windows Platform tools" component.
|
||||
|
|
|
@ -22,10 +22,9 @@ namespace CalcEngine
|
|||
Number::Number(PNUMBER p) noexcept
|
||||
: m_sign{ p->sign }
|
||||
, m_exp{ p->exp }
|
||||
, m_mantissa{}
|
||||
{
|
||||
m_mantissa.reserve(p->cdigit);
|
||||
copy(p->mant, p->mant + p->cdigit, back_inserter(m_mantissa));
|
||||
copy_n(p->mant, p->cdigit, back_inserter(m_mantissa));
|
||||
}
|
||||
|
||||
PNUMBER Number::ToPNUMBER() const
|
||||
|
|
|
@ -101,7 +101,7 @@ CCalcEngine::CCalcEngine(
|
|||
{
|
||||
InitChopNumbers();
|
||||
|
||||
m_dwWordBitWidth = DwWordBitWidthFromeNumWidth(m_numwidth);
|
||||
m_dwWordBitWidth = DwWordBitWidthFromNumWidth(m_numwidth);
|
||||
|
||||
m_maxTrigonometricNum = RationalMath::Pow(10, 100);
|
||||
|
||||
|
|
|
@ -30,17 +30,31 @@ namespace
|
|||
// 0 is returned. Higher the number, higher the precedence of the operator.
|
||||
int NPrecedenceOfOp(int nopCode)
|
||||
{
|
||||
static uint16_t rgbPrec[] = { 0, 0, IDC_OR, 0, IDC_XOR, 0, IDC_AND, 1, IDC_NAND, 1, IDC_NOR, 1, IDC_ADD, 2, IDC_SUB, 2, IDC_RSHF, 3,
|
||||
IDC_LSHF, 3, IDC_RSHFL, 3, IDC_MOD, 3, IDC_DIV, 3, IDC_MUL, 3, IDC_PWR, 4, IDC_ROOT, 4, IDC_LOGBASEY, 4 };
|
||||
|
||||
for (unsigned int iPrec = 0; iPrec < size(rgbPrec); iPrec += 2)
|
||||
switch (nopCode)
|
||||
{
|
||||
if (nopCode == rgbPrec[iPrec])
|
||||
{
|
||||
return rgbPrec[iPrec + 1];
|
||||
}
|
||||
default:
|
||||
case IDC_OR:
|
||||
case IDC_XOR:
|
||||
return 0;
|
||||
case IDC_AND:
|
||||
case IDC_NAND:
|
||||
case IDC_NOR:
|
||||
return 1;
|
||||
case IDC_ADD:
|
||||
case IDC_SUB:
|
||||
return 2;
|
||||
case IDC_LSHF:
|
||||
case IDC_RSHF:
|
||||
case IDC_RSHFL:
|
||||
case IDC_MOD:
|
||||
case IDC_DIV:
|
||||
case IDC_MUL:
|
||||
return 3;
|
||||
case IDC_PWR:
|
||||
case IDC_ROOT:
|
||||
case IDC_LOGBASEY:
|
||||
return 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,7 +532,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
|||
|
||||
if (wParam == IDC_OPENP)
|
||||
{
|
||||
// if there's an omitted multiplication sign
|
||||
// if there's an omitted multiplication sign
|
||||
if (IsDigitOpCode(m_nLastCom) || IsUnaryOpCode(m_nLastCom) || m_nLastCom == IDC_PNT || m_nLastCom == IDC_CLOSEP)
|
||||
{
|
||||
ProcessCommand(IDC_MUL);
|
||||
|
|
|
@ -39,7 +39,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidt
|
|||
if (numwidth >= NUM_WIDTH::QWORD_WIDTH && numwidth <= NUM_WIDTH::BYTE_WIDTH)
|
||||
{
|
||||
m_numwidth = numwidth;
|
||||
m_dwWordBitWidth = DwWordBitWidthFromeNumWidth(numwidth);
|
||||
m_dwWordBitWidth = DwWordBitWidthFromNumWidth(numwidth);
|
||||
}
|
||||
|
||||
// inform ratpak that a change in base or precision has occurred
|
||||
|
@ -50,7 +50,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidt
|
|||
DisplayNum();
|
||||
}
|
||||
|
||||
int32_t CCalcEngine::DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth)
|
||||
int32_t CCalcEngine::DwWordBitWidthFromNumWidth(NUM_WIDTH numwidth)
|
||||
{
|
||||
switch (numwidth)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ uint32_t CCalcEngine::NRadixFromRadixType(RadixType radixtype)
|
|||
// Toggles a given bit into the number representation. returns true if it changed it actually.
|
||||
bool CCalcEngine::TryToggleBit(CalcEngine::Rational& rat, uint32_t wbitno)
|
||||
{
|
||||
uint32_t wmax = DwWordBitWidthFromeNumWidth(m_numwidth);
|
||||
uint32_t wmax = DwWordBitWidthFromNumWidth(m_numwidth);
|
||||
if (wbitno >= wmax)
|
||||
{
|
||||
return false; // ignore error cant happen
|
||||
|
|
|
@ -179,7 +179,7 @@ private:
|
|||
CalcEngine::Rational SciCalcFunctions(CalcEngine::Rational const& rat, uint32_t op);
|
||||
CalcEngine::Rational DoOperation(int operation, CalcEngine::Rational const& lhs, CalcEngine::Rational const& rhs);
|
||||
void SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidth);
|
||||
int32_t DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth);
|
||||
int32_t DwWordBitWidthFromNumWidth(NUM_WIDTH numwidth);
|
||||
uint32_t NRadixFromRadixType(RadixType radixtype);
|
||||
double GenerateRandomNumber();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
// 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
|
||||
|
||||
typedef int32_t ResultCode;
|
||||
using ResultCode = int32_t;
|
||||
|
||||
// CALC_E_DIVIDEBYZERO
|
||||
//
|
||||
|
|
|
@ -156,13 +156,12 @@ namespace UnitConversionManager
|
|||
std::wstring targetCurrencyCode;
|
||||
};
|
||||
|
||||
typedef std::tuple<std::vector<UnitConversionManager::Unit>, UnitConversionManager::Unit, UnitConversionManager::Unit> CategorySelectionInitializer;
|
||||
typedef std::unordered_map<
|
||||
using CategorySelectionInitializer = std::tuple<std::vector<UnitConversionManager::Unit>, UnitConversionManager::Unit, UnitConversionManager::Unit>;
|
||||
using UnitToUnitToConversionDataMap = std::unordered_map<
|
||||
UnitConversionManager::Unit,
|
||||
std::unordered_map<UnitConversionManager::Unit, UnitConversionManager::ConversionData, UnitConversionManager::UnitHash>,
|
||||
UnitConversionManager::UnitHash>
|
||||
UnitToUnitToConversionDataMap;
|
||||
typedef std::unordered_map<int, std::vector<UnitConversionManager::Unit>> CategoryToUnitVectorMap;
|
||||
UnitConversionManager::UnitHash>;
|
||||
using CategoryToUnitVectorMap = std::unordered_map<int, std::vector<UnitConversionManager::Unit>>;
|
||||
|
||||
class IViewModelCurrencyCallback
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace CalculatorApp::ViewModel
|
|||
{
|
||||
std::wstring returnString = L"";
|
||||
const UINT32 length = 1024;
|
||||
std::unique_ptr<wchar_t[]> spBuffer = std::unique_ptr<wchar_t[]>(new wchar_t[length]);
|
||||
std::unique_ptr<wchar_t[]> spBuffer = std::make_unique<wchar_t[]>(length);
|
||||
va_list args = NULL;
|
||||
va_start(args, pMessage);
|
||||
DWORD fmtReturnVal = FormatMessage(FORMAT_MESSAGE_FROM_STRING, pMessage->Data(), 0, 0, spBuffer.get(), length, &args);
|
||||
|
|
|
@ -174,11 +174,11 @@ void UnitConverterViewModel::ResetCategory()
|
|||
m_isInputBlocked = false;
|
||||
SetSelectedUnits();
|
||||
|
||||
UpdateIsDecimalEnabled();
|
||||
|
||||
IsCurrencyLoadingVisible = m_IsCurrencyCurrentCategory && !m_isCurrencyDataLoaded;
|
||||
IsDropDownEnabled = m_Units->GetAt(0) != EMPTY_UNIT;
|
||||
|
||||
UpdateIsDecimalEnabled();
|
||||
|
||||
UnitChanged->Execute(nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,14 +42,3 @@
|
|||
#include "winrt/Windows.UI.Xaml.h"
|
||||
#include "winrt/Windows.Foundation.Metadata.h"
|
||||
#include "winrt/Windows.Management.Policies.h"
|
||||
|
||||
// The following namespaces exist as a convenience to resolve
|
||||
// ambiguity for Windows types in the Windows::UI::Xaml::Automation::Peers
|
||||
// namespace that only exist on RS3.
|
||||
// Once the app switches to min version RS3, the namespaces can be removed.
|
||||
// TODO - MSFT 12735088
|
||||
namespace StandardPeers = Windows::UI::Xaml::Automation::Peers;
|
||||
namespace CalculatorApp::ViewModel::Common::Automation
|
||||
{
|
||||
}
|
||||
namespace CustomPeers = CalculatorApp::ViewModel::Common::Automation;
|
||||
|
|
|
@ -792,9 +792,9 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>6.2.10</Version>
|
||||
<Version>6.2.14</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.0" />
|
||||
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CalcViewModel\CalcViewModel.vcxproj">
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Appium.WebDriver" Version="4.3.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
|
||||
<PackageReference Include="Appium.WebDriver" Version="4.3.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -45,10 +45,6 @@ namespace CalculatorUITestFramework
|
|||
|
||||
public WindowsDriverServiceBuilder WithStartUpTimeOut(TimeSpan startUpTimeout)
|
||||
{
|
||||
if (startUpTimeout == null)
|
||||
{
|
||||
throw new ArgumentNullException("A startup timeout should not be NULL");
|
||||
}
|
||||
this.StartUpTimeout = startUpTimeout;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
|
||||
<PackageReference Include="Appium.WebDriver" Version="4.3.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
|
||||
<PackageReference Include="Appium.WebDriver" Version="4.3.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CalculatorUITestFramework\CalculatorUITestFramework.csproj" />
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Graphing::Analyzer
|
||||
{
|
||||
typedef unsigned int NativeAnalysisType; // PerformAnalysisType
|
||||
using NativeAnalysisType = unsigned int; // PerformAnalysisType
|
||||
|
||||
struct IGraphAnalyzer : public NonCopyable, public NonMoveable
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue