Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

garmin int->float->int fidelity #1134

Open
tsteven4 opened this issue Jun 30, 2023 · 1 comment
Open

garmin int->float->int fidelity #1134

tsteven4 opened this issue Jun 30, 2023 · 1 comment

Comments

@tsteven4
Copy link
Collaborator

clang gives us a warning:

[33/134] Building CXX object CMakeFiles/gpsbabel.dir/garmin.cc.o
/__w/gpsbabel/gpsbabel/garmin.cc:468:25: warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]
        (way[i]->alt == INT_MAX) ||
                     ~~ ^~~~~~~
/usr/lib/llvm-14/lib/clang/14.0.0/include/limits.h:46:19: note: expanded from macro 'INT_MAX'
#define INT_MAX   __INT_MAX__
                  ^~~~~~~~~~~
<built-in>:102:21: note: expanded from here
#define __INT_MAX__ 2147483647
                    ^~~~~~~~~~
1 warning generated.

The more interesting part of this doesn't generate a warning,

ret->smbl = ret->dspl = ret->colour = ret->alt = ret->prot = INT_MAX;

Here smbl, dspl, colour, prot are all int32, but alt is a float. The result of this assignment is that smbl, dspl, colour are set to -2147483648(0x80000000) while prot is set to 2147483647(0x7fffffff), and alt is 2.14748e+09(0x4f000000). I don't know that this causes any trouble, but I doubt that was the intent.

@robertlipe
Copy link
Collaborator

robertlipe commented Jul 1, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants