[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #62283] max (a, b) produces unintuitive result

From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #62283] max (a, b) produces unintuitive results when mixing integers and floating point values
Date: Mon, 6 Jun 2022 07:18:32 -0400 (EDT)

Follow-up Comment #9, bug #62283 (project octave):

The usage of these words for describing the behavior in C++ might not apply
directly to Octave (e.g., because Octave's variables are usually untyped). But
maybe we could try to align as much as possible with how they use these
https://en.cppreference.com/w/cpp/language/implicit_conversion (In particular,
the sections "Numeric promotions" and "Numeric conversions".)

IIUC, they use "promotion" when an integer value changes to a larger integer
type. But only for certain combinations of "source integer type" and "target
integer type". Additionally, changing a single precision floating point value
to a double precision floating point type seems to be called "promotion" in
IIUC, a "promotion" guarantees that the value doesn't change.

Afaict, the "normal" behavior in Octave is to implicitly change double
precision floating point values to single precision floating point type in
mixed operations. I guess the latter could be called "demotion". But I don't
know if that word is used in that context anywhere else.

When it comes to changing the type between integer types not covered by
promotion rules or between integer types and floating point types, they talk
about "conversion" (no guarantee that the value won't change).

IIUC, a conversion between floating point and integer types is never called
"promotion" by them (and probably should neither be called "demotion" in

Afaict, there is no distinction between promotion and conversion in Octave.
But there are also no guarantees that the value won't change. So, would it be
better to talk about "conversions" always? Especially when it comes to values
getting converted between integer and floating point types?


Reply to this item at:


Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]