×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Find the Sign of a Number in C#
 

Submitted by: Srinath M S(srinath_ms@yahoo.com)

Tuesday Jun 19th 2018 by Srinath M S

Language: C#, Expertise: Beginner - See how to determine if a number has a negative sign or positive sign.

System.Math class has a Sign method that will help you determine if a number has a negative sign or positive sign. 

//returns -1 
int negativeNumber  = System.Math.Sign(-2); 
// returns 1
int postiveNumber = System.Math.Sign(1); 
//returns 0
 int neutralNumber = Math.Sign(0); 

Home
Mobile Site | Full Site
Copyright 2018 © QuinStreet Inc. All Rights Reserved