This product is not supported for your selected Datadog site. ().
이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다. 현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.
Metadata
ID:swift-code-style/float-equality
Language: Swift
Severity: Warning
Category: Best Practices
Description
This rule flags instances where floating point values are tested for equality using == or !=. Due to the inherent precision limitations of floating point representation, direct equality comparisons can lead to unreliable or unexpected results. Small rounding errors or differences in representation mean that two values that are conceptually equal might not match exactly when compared.
It is important to avoid direct equality tests on floating point numbers to prevent subtle bugs, especially in financial calculations, scientific computations, or any domain where precision matters. Instead, comparisons should be done using a tolerance or range check, ensuring the values are “close enough” rather than exactly equal.