discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] PMT serialization/deserialization of doubles


From: Dave NotTelling
Subject: [Discuss-gnuradio] PMT serialization/deserialization of doubles
Date: Thu, 16 Jun 2016 18:26:29 -0400

I recently ran across this "bug":


(running ipython)
[code]
In [18]: import pmt

In [19]: pmt.to_double(pmt.deserialize_str(pmt.serialize_str(pmt.from_double(1234567890.0))))
Out[19]: 1234567936.0

In [20]: pmt.to_double(pmt.from_double(1234567890.0))
Out[20]: 1234567890.0
[/code]


Here is the C++ code:

[code]
#include <stdio.h>
#include <stdlib.h>
#include <pmt/pmt.h>

// compiled with "g++ doublesTest.cc -o doublesTest -lgnuradio-pmt"

int main(){
    const double orig = 1234567890.0;
    const double serdes = pmt::to_double(pmt::deserialize_str(pmt::serialize_str(pmt::from_double(orig))));
    const double normal = pmt::to_double(pmt::from_double(orig));

    printf("original:%0.3f, serdes:%0.3f, noserdes:%0.3f\n", orig, serdes, normal);

    return 0;
}
[/code]

[output from c++]
original:1234567890.000, serdes:1234567936.000, noserdes:1234567890.000
[/output from c++]

 Is this an intended outcome?  

Thanks!

-Dave

reply via email to

[Prev in Thread] Current Thread [Next in Thread]