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

Get data in hex format, not float64 #33

Open
cyrillpetroff opened this issue Sep 12, 2023 · 0 comments
Open

Get data in hex format, not float64 #33

cyrillpetroff opened this issue Sep 12, 2023 · 0 comments

Comments

@cyrillpetroff
Copy link

cyrillpetroff commented Sep 12, 2023

#!/usr/bin/perl -w

use Google::ProtocolBuffers;
use File::Slurp qw(read_file write_file);

Google::ProtocolBuffers->parse("
    message TestMessage {
      required double tag1 = 1;
    }
",
    {create_accessors => 1 }
);

my $enc = TestMessage->encode({
tag1 => 0, 
});

open my($fh), ">data.bin";
binmode $fh;
print $fh $enc;
close $fh;

my $dec = read_file('data.bin', { binmode => ':raw' });

my $protoc = TestMessage->decode($dec);

print $protoc->tag1;

And I get 0! Any number is rounded.
But, when I try to use the protoc command, everything is as it should.

C:\Users\user\Desktop>protoc --decode_raw < data.bin 1: 0x0000000000000000

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

1 participant