Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14384] Decimal nextUp/nextDown don't match docs #4217

Closed
swift-ci opened this issue Mar 22, 2021 · 2 comments
Closed

[SR-14384] Decimal nextUp/nextDown don't match docs #4217

swift-ci opened this issue Mar 22, 2021 · 2 comments
Assignees

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-14384
Radar rdar://problem/75697510
Original Reporter ken (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Welcome to Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1).

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee @xwu
Priority Medium

md5: fdfbbd635e018882b0f40276b46b87b4

relates to:

  • SR-14974 Decimal.ulp produces inaccurate results

Issue Description:

The documentation for Decimal's .nextUp says: "The least representable value that is greater than this decimal." Likewise, Decimal's .nextDown is described as: "The greatest representable value that is less than this decimal."

Perhaps I'm misunderstanding what this means (quite possible!), but that's not at all what these properties seem to do:

> Decimal(2).nextUp
$R1: Decimal = 3.000000

It's not just my computer being weird, either. There's unit tests which check this: https://github.com/apple/swift/blob/a73a8087968f9111149073107c5242d83635107a/test/stdlib/TestDecimal.swift#L302-L303

Are there not many other representable Decimal values greater than Decimal(2) and less than Decimal(3)? It's just adding 1.0.

The other FloatingPoint types have the same documentation string, and seem to work as advertised:

> Double(2).nextUp
$R2: Double = 2.0000000000000004
@typesanitizer
Copy link

@swift-ci create

@xwu
Copy link
Collaborator

xwu commented Sep 9, 2021

#3068

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants