Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There are 22 possible narrowing primitive conversions in Java. According to the Java Language Specification, §5.1.3, "Narrowing Primitive Conversions" ,:

  • short to byte or char
  • char to byte or short
  • int to byte, short, or char
  • long to byte, short, char, or int
  • float to byte, short, char, int, or long
  • double to byte, short, char, int, long, or float

...

The CERT C Secure Coding Standard

INT31-C. Ensure that integer conversions do not result in lost or misinterpreted data

 

FLP34-C. Ensure that floating point conversions are within range of the new type

The CERT C++ Secure Coding Standard

INT31-CPP. Ensure that integer conversions do not result in lost or misinterpreted data

 

FLP34-CPP. Ensure that floating point conversions are within range of the new type

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="73b5c135cdc26a11-5ff979e9-46f040f2-a4269aea-0476db4370e245ecbc9016f6"><ac:plain-text-body><![CDATA[

[ISO/IEC TR 24772:2010

http://www.aitcnet.org/isai/]

"Numeric Conversion Errors [FLC]"

]]></ac:plain-text-body></ac:structured-macro>

MITRE CWE

CWE-681, "Incorrect Conversion between Numeric Types"

 

CWE-197, "Numeric Truncation Error"

...