...
Code Block | ||
---|---|---|
| ||
double currentBalance; // User's cash balance void doDeposit(String userInput){ double val; try { val = Double.valueOf(userInput); } catch(NumberFormatException e) { // Handle input format error } if(val >>= Double.MAX_VALUE - currentBalance) { // Handle range error } currentBalance += val; } |
...
Code Block | ||
---|---|---|
| ||
double currentBalance; // User's cash balance void doDeposit(String s){ double val; try { val = Double.valueOf(userInput); } catch(NumberFormatException e) { // Handle input format error } if (Double.isInfinite(val)){ // Handle infinity error } if (Double.isNaN(val)) { // Handle NaN error } if(val >>= Double.MAX_VALUE - currentBalance) { // Handle range error } currentBalance += val; } |
...
Wiki Markup |
---|
\[[IEEE 754|https://www.securecoding.cert.org/confluence/display/seccode/AA.+C+References#AA.CReferences-IEEE7542006|IEEE 754]\]
\[[IEEE 1003.1, 2004|https://www.securecoding.cert.org/confluence/display/seccode/AA.+C+References#AA.CReferences-IEEE1003|IEEE 1003.1, 2004]\] |
...
FLP03-J. Use the strictfp modifier for floating point calculation consistency 07. Floating Point (FLP) FLP30-J. Do not use floating point variables as loop counters