Thanks, you just reminded me there's a really nice section on the encodings
used by capnproto.

On Sat, Nov 4, 2017, 2:10 PM Kenton Varda <[email protected]> wrote:

> Just to be clear: Cap'n Proto specifies that floats are encoded as
> IEEE-754. This happens to be the representation used by all supported
> platforms at present. So there should be no data loss from a round trip.
>
> (Exception: NaNs are weird. Per IEEE-754, there's a bunch of bits in a NaN
> that you can use to encode extra information, but Cap'n Proto does not
> guarantee that those bits will make it to the other end because different
> architectures treat them differently. But if you treat all NaNs the same
> you should be fine.)
>
> -Kenton
>
> On Wed, Nov 1, 2017 at 6:04 PM, Krzysztof Sakrejda <
> [email protected]> wrote:
>
>> I have a schema like so:
>>
>> struct Initialization {
>>   random @0 :Bool = true;
>>   radius @1 :Float64 = 1.0;
>>   file @2 :Text;
>> }
>>
>> and a matching test file to make sure I understand behavior:
>>
>> TEST(initilizationTests, MemoryInitialization) {
>>
>>   const char * initialization_file = "initialize.cs";
>>
>>   ::capnp::MallocMessageBuilder message;
>>   capnStan::Initialization::Builder init =
>> message.initRoot<capnStan::Initialization>();
>>   init.setRandom(true);
>>   init.setRadius(3.3);
>>   init.setFile(initialization_file);
>>
>>   EXPECT_EQ(init.getRandom(), true);
>>   EXPECT_DOUBLE_EQ(init.getRadius(), 3.3);
>>   EXPECT_EQ(init.getRadius(), 3.3);
>>   EXPECT_EQ(std::string(init.getFile().cStr()),
>> std::string(initialization_file));
>> }
>>
>> I was hoping to round-trip a double successfully through the 'radius'
>> field and it works (in so far as the
>> floating point equality and exact equality tests pass).  They likewise
>> pass for a test that writes the message
>> to a file in between.  I was expecting/hoping that this would be the case
>> on a single machine.
>>
>> I'm not so sure about shipping the file between machines with different
>> hardware and what to expect
>> there.  Does anybody have experience with that offhand?
>>
> --
>> You received this message because you are subscribed to the Google Groups
>> "Cap'n Proto" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>
>
>> Visit this group at https://groups.google.com/group/capnproto.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to