Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6850613

Add support for saturated casts

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P5
    • None
    • 7
    • core-libs

    Description

      A DESCRIPTION OF THE REQUEST :
      I post this as a follow up to a discussion that took place on core-libs-dev, titled "Interest in support for saturated casts?"

      It would be great if when fixing "4504839 "Java libraries should provide support for unsigned integer arithmetic", saturated casts could also be provided.

      JUSTIFICATION :
      Modern processors seem to have support for this kind of operation, in
      x86 there's packssdw in MMX/SSE2.

      If the processor doesn't support saturated casts, its just a few lines simple code.

      For now this behaviour has to emulated with, which is quite inefficient:

      return (short) (x > Short.MAX_VALUE ? Short.MAX_VALUE : (x <
      Short.MIN_VALUE ? Short.MIN_VALUE : x));

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Imported:
                Indexed: