Skip to content

Get data in hex format, not float64 #33

Description

@cyrillpetroff
#!/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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions