This is probably just an inconsistency of notation at cplusplus.com, but is there a difference between “long int” and “long” types in C++? cplusplus.com says that abs takes inputs of types “int” and “long”, whereas labs uses “long int”. I assume that this is basically a typo. If so, then is the only difference between abs and labs that labs is guaranteed to return a long?
This is probably just an inconsistency of notation at cplusplus.com , but is there
Share
There is no difference between
longandlong int.The reason we have
abs(long)andlabs(long)(while both are equivalent) is thatlabs()is a remnant of the C library. C doesn’t have function overloading, so functionabs()can only take one type (int) and thelongone has to be called differently, hencelabs.