Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Incorrect functionality preventing creation of -0.0.

-0.0 is a legitimate result of strtod(). Although -0.0 and +0.0 have the same arithmetic value, +0.0 == -0.0, they differ in sign.

// if (signedResult == '-' && result != 0) result = -result;
if (signedResult == '-') result = -result;

If you would like a test to assert if the result is +0.0 or -0.0, consider memcmp() or What operations and functions on +0.0 and -0.0 give different arithmetic results? What operations and functions on +0.0 and -0.0 give different arithmetic results?

double pz = 0.0;
double nz = -0.0;
assert(memcmp(&test_result, &pz, sizeof pz) == 0); // test if canonically the same as +0.0
assert(memcmp(&test_result, &nz, sizeof nz) == 0); // test if canonically the same as -0.0

Incorrect functionality preventing creation of -0.0.

-0.0 is a legitimate result of strtod(). Although -0.0 and +0.0 have the same arithmetic value, +0.0 == -0.0, they differ in sign.

// if (signedResult == '-' && result != 0) result = -result;
if (signedResult == '-') result = -result;

If you would like a test to assert if the result is +0.0 or -0.0, consider memcmp() or What operations and functions on +0.0 and -0.0 give different arithmetic results?

double pz = 0.0;
double nz = -0.0;
assert(memcmp(&test_result, &pz, sizeof pz) == 0); // test if canonically the same as +0.0
assert(memcmp(&test_result, &nz, sizeof nz) == 0); // test if canonically the same as -0.0

Incorrect functionality preventing creation of -0.0.

-0.0 is a legitimate result of strtod(). Although -0.0 and +0.0 have the same arithmetic value, +0.0 == -0.0, they differ in sign.

// if (signedResult == '-' && result != 0) result = -result;
if (signedResult == '-') result = -result;

If you would like a test to assert if the result is +0.0 or -0.0, consider memcmp() or What operations and functions on +0.0 and -0.0 give different arithmetic results?

double pz = 0.0;
double nz = -0.0;
assert(memcmp(&test_result, &pz, sizeof pz) == 0); // test if canonically the same as +0.0
assert(memcmp(&test_result, &nz, sizeof nz) == 0); // test if canonically the same as -0.0
added 20 characters in body
Source Link
chux
  • 36.2k
  • 2
  • 43
  • 96

Incorrect functionality preventing creation of -0.0.

-0.0 is a legitimate result of strtod(). Although -0.0 and +0.0 have the same numricarithmetic value, +0.0 == -0.0, they differ in sign.

// if (signedResult == '-' && result != 0) result = -result;
if (signedResult == '-') result = -result;

If you would like a test to assert if the result is +0.0 or -0.0, consider memcmp() or What operations and functions on +0.0 and -0.0 give different arithmetic results?

double pz = 0.0;
double nz = -0.0;
assert(memcmp(&test_result, &pz, sizeof pz) == 0); // test if canonically the same as +0.0
assert(memcmp(&test_result, &nz, sizeof nz) == 0); // test if canonically the same as -0.0

Incorrect functionality preventing creation of -0.0.

-0.0 is a legitimate result of strtod(). Although -0.0 and +0.0 have the same numric value, they differ in sign.

// if (signedResult == '-' && result != 0) result = -result;
if (signedResult == '-') result = -result;

If you would like a test to assert if the result is +0.0 or -0.0, consider memcmp() or What operations and functions on +0.0 and -0.0 give different arithmetic results?

double pz = 0.0;
double nz = -0.0;
assert(memcmp(&test_result, &pz, sizeof pz) == 0); // test if canonically the same as +0.0
assert(memcmp(&test_result, &nz, sizeof nz) == 0); // test if canonically the same as -0.0

Incorrect functionality preventing creation of -0.0.

-0.0 is a legitimate result of strtod(). Although -0.0 and +0.0 have the same arithmetic value, +0.0 == -0.0, they differ in sign.

// if (signedResult == '-' && result != 0) result = -result;
if (signedResult == '-') result = -result;

If you would like a test to assert if the result is +0.0 or -0.0, consider memcmp() or What operations and functions on +0.0 and -0.0 give different arithmetic results?

double pz = 0.0;
double nz = -0.0;
assert(memcmp(&test_result, &pz, sizeof pz) == 0); // test if canonically the same as +0.0
assert(memcmp(&test_result, &nz, sizeof nz) == 0); // test if canonically the same as -0.0
added 246 characters in body
Source Link
chux
  • 36.2k
  • 2
  • 43
  • 96

Incorrect functionality preventing creation of -0.0.

-0.0 is a legitimate result of strtod(). Although -0.0 and +0.0 have the same numric value, they differ in sign.

// if (signedResult == '-' && result != 0) result = -result;
if (signedResult == '-') result = -result;

If you would like a test to assert if the result is +0.0 or -0.0, consider memcmp() or What operations and functions on +0.0 and -0.0 give different arithmetic results?

double pz = 0.0;
double nz = -0.0;
assert(memcmp(&test_result, &pz, sizeof pz) == 0); // test if canonically the same as +0.0
assert(memcmp(&test_result, &nz, sizeof nz) == 0); // test if canonically the same as -0.0

Incorrect functionality preventing creation of -0.0.

-0.0 is a legitimate result of strtod(). Although -0.0 and +0.0 have the same value, they differ in sign.

// if (signedResult == '-' && result != 0) result = -result;
if (signedResult == '-') result = -result;

If you would like a test to assert if the result is +0.0 or -0.0, consider memcmp() or What operations and functions on +0.0 and -0.0 give different arithmetic results?

Incorrect functionality preventing creation of -0.0.

-0.0 is a legitimate result of strtod(). Although -0.0 and +0.0 have the same numric value, they differ in sign.

// if (signedResult == '-' && result != 0) result = -result;
if (signedResult == '-') result = -result;

If you would like a test to assert if the result is +0.0 or -0.0, consider memcmp() or What operations and functions on +0.0 and -0.0 give different arithmetic results?

double pz = 0.0;
double nz = -0.0;
assert(memcmp(&test_result, &pz, sizeof pz) == 0); // test if canonically the same as +0.0
assert(memcmp(&test_result, &nz, sizeof nz) == 0); // test if canonically the same as -0.0
Source Link
chux
  • 36.2k
  • 2
  • 43
  • 96
Loading
default

AltStyle によって変換されたページ (->オリジナル) /