-5

What does function SIGN(double x,double y) do in C++ language and how to translate it to c#

thb
  • 13,796
  • 3
  • 40
  • 68

3 Answers3

2

A function like that exists in Fortan http://gcc.gnu.org/onlinedocs/gfortran/SIGN.html

SIGN(A,B) returns the value of A with the sign of B.

If B >= 0 then the result is ABS(A), else it is -ABS(A). 

Possibly someone implemented the same function in C++ (but something custom, not a standard part of C++ or the standard libraries).

A c# version of that would be

  A = Math.Abs(A);
  if (B<0.0) A = -A;
1

In the C++ code you are translating to C#, look for a macro definition or inline function definition for SIGN. The definition should spell out exactly how you should implement it in C#.

If I had to guess from the name, SIGN(x,y) returns true if x and y have the same sign, and false otherwise.

jxh
  • 69,070
  • 8
  • 110
  • 193
0

The C++ standard library has no SIGN() function. Your question does not give enough information for me to tell you for certain what this SIGN() is, but C++ succeeds the older programming language C, and my informed hunch is that SIGN() is a preprocessor macro defined in the old C style.

Search your code for a line that begins #define SIGN, possibly with more than one space between the #define and the SIGN. If you find the line, it is likely to tell you what your SIGN() is and does.

thb
  • 13,796
  • 3
  • 40
  • 68