public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Comparison of numerical types
@ 2024-01-21 10:11 Panicz Maciej Godek
  2024-01-21 21:14 ` Per Bothner
  0 siblings, 1 reply; 2+ messages in thread
From: Panicz Maciej Godek @ 2024-01-21 10:11 UTC (permalink / raw)
  To: kawa

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

The equality and comparison predicates on gnu.math.UByte, gnu.math.UInt and
gnu.math.ULong require that they are compared with objects of the same type.

This results in situations, where numbers with identical print
representations are not equal (in the sense of both "equal?" and "=") to
each other, and where the "less than" operator behaves counter-intuitively:


> (define b0 (gnu.math.UByte:valueOf (as byte 241)))
> (= b0 241)
#f
> (< b0 242)
#f

Is there any particular reason for such behavior?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Comparison of numerical types
  2024-01-21 10:11 Comparison of numerical types Panicz Maciej Godek
@ 2024-01-21 21:14 ` Per Bothner
  0 siblings, 0 replies; 2+ messages in thread
From: Per Bothner @ 2024-01-21 21:14 UTC (permalink / raw)
  To: Panicz Maciej Godek, kawa

On 1/21/24 02:11, Panicz Maciej Godek via Kawa wrote:
> The equality and comparison predicates on gnu.math.UByte, gnu.math.UInt and
> gnu.math.ULong require that they are compared with objects of the same type.

no, that is not the case - or at least I don't think it should be
> 
> This results in situations, where numbers with identical print
> representations are not equal (in the sense of both "equal?" and "=") to
> each other, and where the "less than" operator behaves counter-intuitively:

>> (define b0 (gnu.math.UByte:valueOf (as byte 241)))
>> (= b0 241)
> #f
>> (< b0 242)
> #f
> 
> Is there any particular reason for such behavior?

Just a bug. Fixed now.

My guess is this was a copy-paste error - I copied code from the UShort
implementation into the UByte implementation, incorrectly.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-21 21:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-21 10:11 Comparison of numerical types Panicz Maciej Godek
2024-01-21 21:14 ` Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).