Bug 1786

Summary: os << int64x64_t prints un-normalized fractional values
Product: ns-3 Reporter: Peter Barnes <pdbarnes>
Component: coreAssignee: Mathieu Lacage <mathieu.lacage>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, pdbarnes, tommaso.pecorella
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   
See Also: https://www.nsnam.org/bugzilla/show_bug.cgi?id=1856

Description Peter Barnes 2013-10-28 15:01:17 UTC
int64x64_t val = 5.6;
  std::cout << val << std::endl;

prints

  +5.11068046444225724416

The output streamer in int64x64.cc fails to normalize the fractional part.

This passes tests because the un-normalized value is hard-coded as the correct result.

Patch coming...
Comment 1 Peter Barnes 2014-01-10 20:28:19 UTC
Commit e08d256cdffc
http://code.nsnam.org/ns-3-dev/rev/e08d256cdffc
Comment 2 Peter Barnes 2014-01-29 22:16:02 UTC
[Bug 1786] Fix for os << (int64x64_t) and fractional arithmetic

Arithmetic with fractions was never tested and it had lots of bugs.
This patch set:

- Defines many more tests, giving complete coverage of all operations
(signed/unsigned, integer, fractions, mixed)

- Replaces over-generous #define creation of functions with minimal
set of C++ functions.

- Minimizes differences between implementations.

- Documents all functions.

int128 and cairo implementations agree exactly on all int64x64 tests,
and pass all ns-3 tests.

long double implementation agrees with the other two on most int64x64
tests; failures have to do with less precision in long doubles.
The prior double implementation failed five ns-3 tests:
    devices-mesh-dot11s-regression
    devices-mesh-flame-regression
    int64x64
    routing-aodv-regression
    routing-olsr-regression
This implementation fails routing-olsr-regression because of single
bit differences in the pcap files.

Commit: 6e1bd685bcaa
http://code.nsnam.org/ns-3-dev/rev/6e1bd685bcaa
Comment 3 Tommaso Pecorella 2014-02-05 01:59:33 UTC
Changeset http://code.nsnam.org/ns-3-dev/rev/540e54a98bc8

introduced an error: when "cairo_impl64" is not declared (perhaps because you don't have cairo headers), compilation fails:

../src/core/test/int64x64-test-suite.cc:819:41: error: use of undeclared identifier 'cairo_impl64'
      std::cout << "cairo_impl64:  " << cairo_impl64 << std::endl;
                                        ^
../src/core/test/int64x64-test-suite.cc:820:41: error: use of undeclared identifier 'cairo_impl128'
      std::cout << "cairo_impl128: " << cairo_impl128 << std::endl;
                                        ^
2 errors generated.
Waf: Leaving directory `/Users/pecos/Development/workspace/ns-3-dev/build'
Build failed
Comment 4 Tommaso Pecorella 2014-02-05 16:32:56 UTC
Fixed in changeset 10611 5390474ca6b7
Comment 5 Peter Barnes 2014-03-02 04:09:46 UTC
Fixed again in

Patch r10637 67601c471c22
http://code.nsnam.org/ns-3-dev/rev/67601c471c22