6 Mayıs 2016 Cuma

AXAPTA - Sign function doesn't work correctly

Sign function doesn't work correctly in AX 2009 and 2012. It should returns -1 for negative numbers, 0 for zero and +1 for positive numbers. But  it gives -1 for negative and +1 for others.

Sign at Global:

static real sign(real num)
{
    return num >= 0 ? 1 : -1;
}


My correction:

static int sign(real num)
{

   if (num < 0)
    return -1;
   else
    return num > 0 ? 1 : 0;
}

Hiç yorum yok:

Yorum Gönder