Skip to content

Conversation

@amartini51
Copy link
Member

Summary of changes:

  • Added a mention of fixed-point math
  • Call out finance and other areas where neither int nor float is sufficient
  • Contrast integers as "counting numbers" with floating-point numbers as "measurements"
  • Added a mention of special values like negative zero and NaN

Fixes: rdar://122436757

This list is currently missing 128-bit numbers, and we could get more
integer types in the future.  There's no reason to duplicate all of them
here -- it will just get out of date again, and isn't needed as part of
introducing the integer type.
- Per TR, correct the framing of floating-point as having a margin of
  error in the result of calculations, not as themselves being inexact.
- Match the flow from the integer section, first introducing the
  floating-point types and then describing them (and contrasting their
  behavior to integer math).
- Show an example of the change in value spacing (ulp) between
  large/small floating-point numbers.

Co-authored-by: Steve Canon <scanon@apple.com>
Copy link
Member Author

@amartini51 amartini51 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @stephentyrone for the corrections! Incorporated your feedback and re-ordered some prose to make it flow better.

Another piece of context I don't think I mentioned. I'm trying to give developers enough information about what makes floating-point math different that they can make an informed decision — so they can avoid the tripping hazard of assuming every number that includes a decimal point should be a Double. But also trying to scare folks away from using "weird floating-point math" when that actually is the right data type.

Co-authored-by: Steve Canon <scanon@apple.com>
Copy link

@colleenish colleenish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass edits. Let me know if you have any questions.

Edits from <rdar://162699805>

Co-authored-by: Colleen Toporek <colleen_toporek@apple.com>
Copy link

@colleenish colleenish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second pass. One follow-up fix.

Copy link

@colleenish colleenish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; no additional changes from me.

@amartini51 amartini51 merged commit 07fbec5 into swiftlang:main Oct 21, 2025
@amartini51 amartini51 deleted the numbers_122436757 branch October 21, 2025 21:46
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.

4 participants