strong_ordering fn( float a, float b )
{
partial_ordering po = a <=> b;
if( po == partial_ordering::unordered ) [[unlikely]]
throw invalid_argument( "hello world" );
return bit_cast<strong_ordering>( a <=> b );
}
;-)
On Mon, 26 May 2025 12:05:41 +0200, Bonita Montero wrote:
strong_ordering fn( float a, float b )
{
partial_ordering po = a <=> b;
if( po == partial_ordering::unordered ) [[unlikely]]
throw invalid_argument( "hello world" );
return bit_cast<strong_ordering>( a <=> b );
}
;-)
It is unwise to compare floating point numbers for equality.
Sysop: | Tetrazocine |
---|---|
Location: | Melbourne, VIC, Australia |
Users: | 11 |
Nodes: | 8 (0 / 8) |
Uptime: | 51:42:52 |
Calls: | 166 |
Files: | 21,502 |
Messages: | 77,746 |