Bas Arts Posted August 27, 2014 Report Share Posted August 27, 2014 I tried to write and read an unsigned long long value over a double channel, using a double value as starting point. Code snippet: double d = 3.1415926535897931; unsigned long long * ullp = (unsigned long long *) &d; out_port.write(*ullp); // sc_out<double> out_port; connected via sc_signal<double> to in_port unsigned long long ull = in_port.read(); // sc_in<double> in_port; connected via sc_signal<double> to out_port double * dp = (double *) &ull; When I print the values of d, *ullp, ull and *dp, I notice the following: d: 3.1415926535897931; *ullp: 4614256656552045848; ull: 4614256656552045568; *dp: 3.1415926535896688; However, plain casting without SystemC (double d -> ull* ullp = (ull*) &d -> ull u = *ullp -> double* dp = (double*) &u -> double d2 = *dp) returns d2 with exactly the same value as d. Any idea what is happening and why the channel of type double seems to loose a bit of its precision when using it in this way? -- greetz, Bas Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.