Unidata / UDUNITS-2

API and utility for arithmetic manipulation of units of physical quantities
http://www.unidata.ucar.edu/software/udunits
Other
62 stars 36 forks source link

Warning about using integer abs on a float. #68

Closed schwehr closed 6 years ago

schwehr commented 6 years ago

While this may work okay in the code, it would be good to have this be more explicit. Either case numer to an int before calling abs or use fabs and cast to and int before dividing. Alternatively, this could have some cases that may be incorrect. Without looking closer, I can't tell.

udunits/lib/unitcore.c:415:19: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
    int n = (int)(abs(numer)/denom);

abs takes an integer arg: http://www.cplusplus.com/reference/cstdlib/abs/

semmerson commented 6 years ago

The next release won't have this lint.

schwehr commented 6 years ago

What commit? I am working from git -> perforce rather than point releases so I can track these issues from inside my system.

semmerson commented 6 years ago

Does your Perforce software have the ability to perform the equivalent of a "git pull"?

schwehr commented 6 years ago

Yes. But I mostly work through patches by hand coming from ’git format-patch’. More like working with patchsets and quilt

semmerson commented 6 years ago

@schwehr , that might not be the most convenient way to work with Git and GitHub. It's certainly not for me. Good luck.

schwehr commented 6 years ago

As long as you follow the normal conventions for git and github, I should be able to follow along without trouble.

I was just asking you to do what I just did by commenting in the commit with this issue number. Then I can follow along what you are doing much easier. I had assumed that you meant you were not pushing commits to github, but you are, which is great! Thanks for the fix. I assumed that you were putting the issue in the commit message. If you haven't tried it, you can say closes #68 in the commit message and the issue will get closed and be easy to follow for others.

See https://help.github.com/articles/closing-issues-using-keywords/

semmerson commented 6 years ago

@schwehr I did not know that. I'll try to remember. Thanks.