Skip to content

Read 0x10 in the field's calculator as sixteen, not 0 × 10 - #1141

Open
r0c0y wants to merge 1 commit into
yetanotherbrowser:mainfrom
r0c0y:fix-calculator-hex-digits
Open

r0c0y wants to merge 1 commit into
yetanotherbrowser:mainfrom
r0c0y:fix-calculator-hex-digits

Conversation

@r0c0y

@r0c0y r0c0y commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What changes

The command field's calculator reads 0x10 as sixteen, a hex number, instead of 0 × 10. 0x400 is 1,024, not 0.

Fixes #1140

Why it happened

Calc.answer asks the sum reader before Calc.base. The sum reader (Sum.answer) takes an x between two numbers for times, so a hex number written only with the digits 0 to 9 was zero times the rest. One with a letter in it (0xff) can't be a sum, so it reached Calc.base.

Sum.answer now leaves an x right after a 0 that starts a number to Calc.base, which reads 0x10 as hex. Sums with an x for times read as before: 3x4, 10x10, 1.0x10, and 0 x 10 with spaces. A hex number inside a sum (0x10+1) now gets no answer instead of 1, since the calculator doesn't read hex inside a sum.

Proof

  • Logic: a test that fails on main and passes here: swift test --filter CalcTests (aHexNumberInDecimalDigitsIsNotASum)

I can't build Yab here (no Xcode). Instead I compiled Calculator.swift on its own, with a stub for Store, and ran the synchronous tests of CalcTests through a small runner. That is 17 tests; the async rate tests and the artwork test need the app.

Typed main This branch
0x10 0 16
0x400 0 1,024
0x10+1 1 no answer
0xff 255 255
10x10 100 100
1.0x10 10 10
0 x 10 0 0

On main the new test fails on 5 of its lines. Every other test the runner covers passes on both. The sums in FieldTests (3x4 and the rest) have no 0x in them.

Checked on

  • Yab Dev built from this branch on macOS: not built here (no Xcode). Calculator.swift compiled and run on macOS 27.2.1 with Swift 6.2.1.
  • Engine(s) tried: not about a page

Checklist

  • swift test passes (or the suites this touches: list them): CalcTests, not run with swift test here; the runner above covers its synchronous tests
  • ./design-check --head is clean, or each exception says why with // design:
  • Anything that changes how Yab looks was approved in the issue first (nothing changes but the wrong number)
  • A new menu item is also a command in the field; a new Settings row is classified in NativeActions.swift (none)
  • Words on screen and in docs are American English, with no em dashes

This adds one check at the top of Sum.answer, away from the lines #946 (Calc.base) and #959 (Sum.Parser) change.

Written by an AI coding agent (Claude Code, Claude Opus 5.5) at my request.

A hex number written only with the digits 0 to 9 reached the sum reader
first, which takes an x between numbers for times: 0x10, 0x400 and 0x80
all answered 0. The sum reader now leaves an x right after a 0 that
starts a number to Calc.base, which reads it as hex. "0 x 10" with
spaces, "10x10" and "1.0x10" are still sums.
@r0c0y
r0c0y requested a review from serafimcloud as a code owner November 25, 2026 09:18
@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable defects were found.

Summary

The calculator now leaves digit-only hex numbers such as 0x10 to Calc.base instead of reading them as multiplication.

  • The field’s calculator reads 0x10 as sixteen.

Reviews (1) · Last reviewed commit: "Read 0x10 in the field's calculator as s..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command field calculator answers 0 for 0x10, and for any hex number written with only the digits 0 to 9

1 participant