-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] More verbose debugDescription for NaN #2786
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
Conversation
#if !arch(i386) | ||
expectDebugPrinted("snan", Float.signalingNaN) | ||
expectDebugPrinted("snan(0xffff)", Float(nan: 65535, signaling: true)) | ||
expectDebugPrinted("-snan(0xffff)", -Float(nan: 65535, signaling: true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add tests with the largest possible payload, to make sure that high bits are not dropped in any of the conversions?
expectDebugPrinted("nan(0xffff)", Float(nan: 65535, signaling: false)) | ||
expectDebugPrinted("-nan(0xffff)", -Float(nan: 65535, signaling: false)) | ||
expectDebugPrinted("nan(0x1fffff)", Float(bitPattern: 0x7fff_ffff)) | ||
expectDebugPrinted("nan(0x1fffff)", Float(bitPattern: 0x7fdf_ffff)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, current implementation drops MSB of payload bits,
because that bit is reserved for placeholder payload of signaling NaN.
I'm not sure whether this behavior is reasonable or not. @stephentyrone ?
To clarify the largest NaN payload value. |
@swift-ci Please test |
} | ||
let isSignaling = (significand & Float${bits}._quietNaNMask) == 0 | ||
let payload = significand & ((Float${bits}._quietNaNMask >> 1) - 1) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a FIXME
note here, as these string manipulations are inefficient enough to make someone want to optimize them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, we could move some of the string concatenation into the C function that we are calling below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually use FIXME(performance)
for these kinds of notes.
Minor note: there is enough repetition in |
Oh, and yes, for the record, Linux build failure is unrelated. |
@moiseev Format looks good. |
The format of debugDescription for NaN is: [ '-' ] ( 'snan' | 'nan' ) [ '(0x' hexadecimal-digits ')' ]
Added |
What's in this pull request?
Follow-up on #1922
Now, the format of
debugDescription
for NaN is:-
[(0x
hexadecimal-digits)
]@stephentyrone
Could you confirm the format?
@gribozavr
Should we use more high level APIs?
Before merging this pull request to apple/swift repository: