Files
PowerToys/.github/actions/spell-check/allow/code.txt
Dave Rayment e17454b553 [CmdPal Calculator] Add rand() and randi(). Expand result responses to differentiate between NaN and ParseError (#47725)
## Summary of the Pull Request
This adds `rand()` and `randi()` functions to Command Palette's
Calculator, making it consistent with Run.

It also expands upon the return values from `ToWStringFullPrecision()`,
so NaN, ParseError and +/-infinity results are passed back to the
caller, improving the specificity of the error message display.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #47707
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
The two new functions have been added to **ExprtkEvaluator.cpp**,
alongside `sign()` and `factorial()`. As they need to handle the state
of the RNG, they're slightly more complex in implementation. I used the
Mersenne Twister RNG with a uniform distribution, and the instances are
marked `static thread_local` in case the engine moves to multithreaded
evaluation in the future.

It's possible for the RNG to return a value out of the range of
`double`, and this is caught and `quiet_NaN()` is returned. To prevent
this being caught as a generic parse error, I updated
`ToWStringFullPrecision()` to distinguish between `NaN`, expression
parsing errors and infinity values. This should improve the accuracy of
error messages for other expressions, too.

Finally, I corrected a comment in **CalculateEngine.cs,** which still
referred to the Mages calculation engine. The log/ln mapping is the same
for both engines, so the comment was still accurate except for this
reference.

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Unit tests were added to exercise the new functions. All Calculator
tests pass:

<img width="375" height="59" alt="image"
src="https://github.com/user-attachments/assets/5a33e1ed-a4fd-4d53-b9ba-6b44000f1bf4"
/>

Confirmed that error messages are displaying correctly for the
newly-exposed result types:

**Not a number**
<img width="787" height="128" alt="image"
src="https://github.com/user-attachments/assets/8c73dcf6-122b-4af8-bf1a-62284842433a"
/>

<img width="786" height="145" alt="image"
src="https://github.com/user-attachments/assets/fe14338c-1160-4aae-83dd-5ca3491ae59e"
/>

**+/- Infinity**
<img width="898" height="137" alt="image"
src="https://github.com/user-attachments/assets/20cfacda-72a7-44bb-a875-af7be39ee7e2"
/>

**Parser failure**
<img width="607" height="139" alt="image"
src="https://github.com/user-attachments/assets/7d7120b2-a2cf-45b6-ab89-79af4051fa50"
/>

<img width="587" height="140" alt="image"
src="https://github.com/user-attachments/assets/2dc7a365-7ee6-4379-8b3f-47b3912e6891"
/>
2026-05-16 19:50:58 +00:00

420 lines
3.7 KiB
Plaintext

# COLORS
argb
Bgr
bgra
BLACKONWHITE
BLUEGRAY
BRIGHTGREEN
COLORONCOLOR
DARKPURPLE
DARKTEAL
DARKYELLOW
Farbraum
ICEBLUE
LIGHTORANGE
LIGHTTURQUOISE
NCol
OLIVEGREEN
PALEBLUE
PArgb
Pbgra
SRGBTo
WHITEONBLACK
# COUNTRIES
RUS
# FILES
AYUV
bak
HDP
Bcl
bgcode
Deflatealgorithm
exa
exabyte
Gbits
Gbps
gcode
Heatshrink
Mbits
Kbits
MBs
mkv
msix
nupkg
petabyte
resw
resx
srt
Stereolithography
terabyte
UYVY
xbf
YUY
YUYV
YVU
YVYU
zipfolder
CODEOWNERS
VNext
vnext
# FONTS
Consolas
Neue
Noto
Roboto
Segoe
# IN URLs
accessibilityinsights
arik
epicgames
fwlink
joefinapps
lepo
linkedin
oblitum
robmensching
sinclairinat
stylecop
uipi
yinwang
myaccess
onmicrosoft
aep
epsf
howto
onefuzzconfig
oip
onefuzzingestionpreparationtool
OTP
Yubi
Yubico
Perplexity
Groq
svgl
devhome
# KEYS
altdown
BUTTONUP
bafunctions
Baf
Bitness
BUILDARCHSHORT
CTRLALTDEL
Ctrls
CSilent
CBal
CREATEBAFUNCTIONS
CPrereq
dirutil
DUtil
Editbox
EXSEL
HOLDENTER
HOLDESC
HOLDSPACE
HOLDBACKSPACE
IDIGNORE
KBDLLHOOKSTRUCT
keydowns
keyevent
LAlt
LBUTTON
LBUTTONDBLCLK
LBUTTONDOWN
LBUTTONUP
LCONTROL
LCtrl
LEFTDOWN
LEFTUP
locutil
logutil
msimg
MBUTTON
MBUTTONDBLCLK
MBUTTONDOWN
MBUTTONUP
MIDDLEDOWN
MIDDLEUP
memutil
NCRBUTTONDBLCLK
NCRBUTTONDOWN
NCRBUTTONUP
NUMLOCK
RBUTTON
RBUTTONDBLCLK
RBUTTONDOWN
RBUTTONUP
RCONTROL
RCtrl
RIGHTDOWN
RIGHTUP
Richedit
rgwz
resrutil
srd
scz
shelutil
thmutil
uriutil
VKTAB
wcautil
winkey
wininet
WMKEYDOWN
WMKEYUP
WMSYSKEYDOWN
WMSYSKEYUP
XBUTTON
XBUTTONDBLCLK
XBUTTONDOWN
XBUTTONUP
XDOWN
xmlutil
# Prefix
pcs
# EXPRTK / C++ MATH
ifunction
isinf
isnan
# User32.SYSTEM_METRICS_INDEX.cs
CLEANBOOT
CMOUSEBUTTONS
CONVERTIBLESLATEMODE
CXBORDER
CXCURSOR
CXDLGFRAME
CXDLGFRAME
CXDOUBLECLK
CXDRAG
CXEDGE
CXFIXEDFRAME
CXFOCUSBORDER
CXFRAME
CXFRAME
CXFULLSCREEN
CXHSCROLL
CXHTHUMB
CXICON
CXICONSPACING
CXMAXIMIZED
CXMAXTRACK
CXMENUCHECK
CXMENUSIZE
CXMIN
CXMINIMIZED
CXMINSPACING
CXMINTRACK
CXPADDEDBORDER
CXSIZE
CXSIZEFRAME
CXSMSIZE
CXVSCROLL
CYBORDER
CYCAPTION
CYCURSOR
CYDLGFRAME
CYDLGFRAME
CYDOUBLECLK
CYDRAG
CYEDGE
CYFIXEDFRAME
CYFOCUSBORDER
CYFRAME
CYFRAME
CYFULLSCREEN
CYHSCROLL
CYICON
CYICONSPACING
CYKANJIWINDOW
CYMAXIMIZED
CYMAXTRACK
CYMENU
CYMENUCHECK
CYMENUSIZE
CYMIN
CYMINIMIZED
CYMINSPACING
CYMINTRACK
CYSIZE
CYSIZEFRAME
CYSMCAPTION
CYSMSIZE
CYVSCROLL
CYVTHUMB
DBCSENABLED
IMMENABLED
MAXIMUMTOUCHES
MEDIACENTER
MENUDROPALIGNMENT
MIDEASTENABLED
MOUSEHORIZONTALWHEELPRESENT
MOUSEPRESENT
MOUSEWHEELPRESENT
PENWINDOWS
REMOTECONTROL
REMOTESESSION
SAMEDISPLAYFORMA
SERVERR
SHOWSOUNDS
SHUTTINGDOWN
SLOWMACHINE
SWAPBUTTON
SYSTEMDOCKED
TABLETPC
# Units
nmi
# MATH
artanh
arsinh
arcosh
roundf
# Linux
dbus
anypass
github
gpg
https
ssh
ubuntu
workarounds
# For upgrade to check-spelling v0.0.24
pwa
# .NET
AOT
Aot
ify
TFM
# YML
onefuzz
# NameInCode
leilzh
mengyuanchen
contoso
# DllName
testhost
Testably
#Tools
OIP
xef
xes
PACKAGEVERSIONNUMBER
APPXMANIFESTVERSION
PROGMAN
# MRU lists
CACHEWRITE
MRUCMPPROC
MRUINFO
REGSTR
# Misc Win32 APIs and PInvokes
DEFAULTTONEAREST
INVOKEIDLIST
LCMAP
MEMORYSTATUSEX
ABE
Mdt
HTCAPTION
POSCHANGED
QPC
QUERYPOS
SETAUTOHIDEBAR
ULW
WINDOWPOS
WINEVENTPROC
WORKERW
FULLSCREENAPP
DEFAULTTONEAREST
# COM/WinRT interface prefixes and type fragments
BAlt
BShift
Cmanifest
Cmodule
Cuuid
Dng
IApplication
IDisposable
IEnum
IFolder
IInitialize
IMemory
IOle
ipreview
IProperty
IShell
ithumbnail
IVirtual
# Test frameworks
MSTEST
# PowerRename metadata pattern abbreviations (used in tests and regex patterns)
DDDD
FFF
HHH
riday
YYY
# Unicode
precomposed
# names of characters
zwsp
# mermaid
autonumber
# GitHub issue/PR commands
azp
feedbackhub
needinfo
reportbug
#ffmpeg
crf
nostdin
# Performance counter keys
engtype
Nonpaged
# XAML
Untargeted
# Program names
SEARCHHOST
SHELLEXPERIENCEHOST
SHELLHOST
STARTMENUEXPERIENCEHOST
WIDGETBOARD