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

Problem with function get_latitude_or_longitude #8

Open
cmarmonier opened this issue Feb 2, 2024 · 1 comment
Open

Problem with function get_latitude_or_longitude #8

cmarmonier opened this issue Feb 2, 2024 · 1 comment

Comments

@cmarmonier
Copy link

cmarmonier commented Feb 2, 2024

I'm no sure but I think there is a problem with function get_latitude_or_longitude() in file epan/dissectors/packet-lldp.c.

	...
	/* Calculate decimal portion (using 25 bits for fraction) */
	tempValue = (tempValue & G_GINT64_CONSTANT(0x0000000001FFFFFF))/33554432;
	...
	return wmem_strdup_printf(wmem_packet_scope(), "%u.%04" G_GINT64_MODIFIER "u degrees %s",
	    integerPortion, tempValue, direction);

Type of tempValue is guint64... maximum value of tempValue is 0x1FFFFFF... 0x1FFFFFF / 33554432 = 0 => I think that floating-point numbers should always be ".0000" with printf.

Can you confirm ?

@vedangipatil117
Copy link

You might revise function as
/* Calculate decimal portion (using 25 bits for fraction) */
tempValue = (tempValue & G_GINT64_CONSTANT(0x0000000001FFFFFF));
tempValue = (tempValue * 10000) / 33554432; // Scale to 4 decimal places

return wmem_strdup_printf(wmem_packet_scope(), "%u.%04" G_GINT64_MODIFIER "u degrees %s",
integerPortion, tempValue, direction);

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