Bug 1786 - os << int64x64_t prints un-normalized fractional values
os << int64x64_t prints un-normalized fractional values
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
ns-3-dev
All All
: P5 normal
Assigned To: Mathieu Lacage
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-28 15:01 EDT by Peter Barnes
Modified: 2014-03-02 04:09 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Barnes 2013-10-28 15:01:17 EDT
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 EST
Commit e08d256cdffc
http://code.nsnam.org/ns-3-dev/rev/e08d256cdffc
Comment 2 Peter Barnes 2014-01-29 22:16:02 EST
[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 EST
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 EST
Fixed in changeset 10611 5390474ca6b7
Comment 5 Peter Barnes 2014-03-02 04:09:46 EST
Fixed again in

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