[lkml]   [2001]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [IDEA+RFC] Possible solution for min()/max() war
    Graham Murray <> writes:

    > Daniel Phillips <> writes:
    > > More than anything, it shows that education is needed, not macro patch-ups.
    > > We have exactly the same issues with < and >, should we introduce
    > > three-argument macros to replace them?
    > Would it not have been much more "obvious" if the rules for
    > unsigned/signed integer comparisons (irrespective of the widths
    > involved) were
    > 1) If the signed element is negative then it is always less than the
    > unsigned element.
    > 2) If the unsigned element is greater than then maximum positive value
    > expressible by the signed one then it is always greater.
    > 3) Only if both values are positive and within the range of the
    > smaller element are the actual values compared.

    With infinite-precision arithmetic, yes; of course min() should just
    return the smaller value.

    But what would the C type of "min" be for comparing, say, signed and
    unsigned longs? The range of possible results does not fit in any
    integral type. (Repeat the question for signed/unsigned "long long"
    if "long long" is your answer.)

    - Pat
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:01    [W:0.023 / U:4.552 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site