What is the function to determine the min and max possible of value of datatypes (i.e, int, char.etc) in C?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’ll want to use
limits.hwhich provides the following constants (as per the linked reference):Where
U*_MINis omitted for obvious reasons (any unsigned type has a minimum value of0).Similarly
float.hprovides limits forfloatanddoubletypes:Floating point types are symmetrical around zero, so the most negative finite number is the negation of the most positive finite number – eg
floatranges from-FLT_MAXtoFLT_MAX.Do note that floating point types can only exactly represent a small, finite number of values within their range. As the absolute values stored get larger, the spacing between adjacent numbers that can be exactly represented also gets larger.