[PR #5150] [MERGED] add til::math, use it for float conversions to point, size #26146

Open
opened 2026-01-31 09:14:15 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5150
Author: @DHowett-MSFT
Created: 3/27/2020
Status: Merged
Merged: 3/27/2020
Merged by: @undefined

Base: masterHead: dev/duhowett/til_i_can_do_math


📝 Commits (2)

  • 138c6b9 add til::math and magic converters
  • dc1677c fix speeling, allowlist cxcy/isnan

📊 Changes

11 files changed (+490 additions, -0 deletions)

View changed files

📝 .github/actions/spell-check/dictionary/math.txt (+1 -0)
📝 .github/actions/spell-check/whitelist/whitelist.txt (+1 -0)
📝 src/inc/til.h (+1 -0)
src/inc/til/math.h (+85 -0)
📝 src/inc/til/point.h (+16 -0)
📝 src/inc/til/size.h (+24 -0)
src/til/ut_til/MathTests.cpp (+127 -0)
📝 src/til/ut_til/PointTests.cpp (+97 -0)
📝 src/til/ut_til/SizeTests.cpp (+136 -0)
📝 src/til/ut_til/sources (+1 -0)
📝 src/til/ut_til/til.unit.tests.vcxproj (+1 -0)

📄 Description

This pull request introduces the til::math namespace, which provides some casting functions to be used in support of til::point and til::size. When point/size want to ingest a floating-point structure, they must be instructed on how to convert those floating-point values into integers.

This enables:

Windows::Foundation::Point wfPoint = /* ... */;
til::point tp{ til::math::rounding, wfPoint };

Future thoughts: should the TilMath types be stackable? Right now, you cannot get "checked + rounding" behavior (where it throws if it doesn't fit) so everything is saturating.

PR Checklist

  • Closes a request by Michael
  • I've discussed this with core contributors already

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/5150 **Author:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Created:** 3/27/2020 **Status:** ✅ Merged **Merged:** 3/27/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/duhowett/til_i_can_do_math` --- ### 📝 Commits (2) - [`138c6b9`](https://github.com/microsoft/terminal/commit/138c6b945a57fbbae167bd27bdfc78b091cbcdf9) add til::math and magic converters - [`dc1677c`](https://github.com/microsoft/terminal/commit/dc1677c4741531dd85a68ae7e22d6dc44cded853) fix speeling, allowlist cxcy/isnan ### 📊 Changes **11 files changed** (+490 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spell-check/dictionary/math.txt` (+1 -0) 📝 `.github/actions/spell-check/whitelist/whitelist.txt` (+1 -0) 📝 `src/inc/til.h` (+1 -0) ➕ `src/inc/til/math.h` (+85 -0) 📝 `src/inc/til/point.h` (+16 -0) 📝 `src/inc/til/size.h` (+24 -0) ➕ `src/til/ut_til/MathTests.cpp` (+127 -0) 📝 `src/til/ut_til/PointTests.cpp` (+97 -0) 📝 `src/til/ut_til/SizeTests.cpp` (+136 -0) 📝 `src/til/ut_til/sources` (+1 -0) 📝 `src/til/ut_til/til.unit.tests.vcxproj` (+1 -0) </details> ### 📄 Description This pull request introduces the `til::math` namespace, which provides some casting functions to be used in support of `til::point` and `til::size`. When point/size want to ingest a floating-point structure, they _must_ be instructed on how to convert those floating-point values into integers. This enables: ``` Windows::Foundation::Point wfPoint = /* ... */; til::point tp{ til::math::rounding, wfPoint }; ``` Future thoughts: should the TilMath types be stackable? Right now, you cannot get "checked + rounding" behavior (where it throws if it doesn't fit) so everything is saturating. ## PR Checklist * [x] Closes a request by Michael * [x] I've discussed this with core contributors already --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:14:15 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26146