Unary Operator-() on zero values - c++ -
i wrote code overload unary operator- on matrix class:
const regmatrix regmatrix::operator-()const{ regmatrix result(numrow,numcol); int i,j; for(i=0;i<numrow;++i) for(j=0;j<numcol;++j){ result.setelement(i,j,(-_matrix[i][j])); } return result; }
when ran program debugger in visual studio, showed me when operation done on double equals zero, inserts result matrix number -0.00000. weird vs-display feature, or should handle carefully?
signed 0 zero associated sign. in ordinary arithmetic, −0 = +0 = 0. however, in computing, number representations allow existence of 2 zeros, denoted −0 (negative zero) , +0 (positive zero). occurs in signed number representations integers, , in floating point number representations. number 0 encoded +0, can represented either +0 or −0.
the ieee 754 standard floating point arithmetic (presently used computers , programming languages support floating point numbers) requires both +0 , −0. zeroes can considered variant of extended real number line such 1/−0 = −∞ , 1/+0 = +∞, division 0 undefined ±0/±0.
negatively signed 0 echoes mathematical analysis concept of approaching 0 below one-sided limit, may denoted x → 0−, x → 0−, or x → ↑0. notation "−0" may used informally denote small negative number has been rounded zero. concept of negative 0 has theoretical applications in statistical mechanics , other disciplines.
it claimed inclusion of signed 0 in ieee 754 makes easier achieve numerical accuracy in critical problems,1 in particular when computing complex elementary functions.[2] on other hand, concept of signed 0 runs contrary general assumption made in mathematical fields (and in mathematics courses) negative 0 same thing zero. representations allow negative 0 can source of errors in programs, software developers not realize (or may forget) that, while 2 0 representations behave equal under numeric comparisons, different bit patterns , yield different results in operations.
for more information see signed zero wiki page.
Comments
Post a Comment