Quantcast
Channel: Tools
Viewing all articles
Browse latest Browse all 91752

Forum Post: RE: Typecast issue (int - long) with compiler 4.1.3 (TMS320F2812)

$
0
0

Thanks for your advice it is working.

Let me do distruction to C++ code. We have following code and compiler optimization level as 2 (-o2)

double value = -34.234;
m_real_double = (double)value;
m_ulong = (unsignedlong)m_real_double;
m_long = (long)m_real_double; 

Results from such code is m_ulong =0 and m_long=0. Based on your mail I would expect m_ulong=0 and m_long = -34;

We made few experimentation and found out how to get expected result. It seems there is some issue with C++ compiler.
1) use -o1
2) reorder instruction in this way

double value = -34.234;
m_real_double = (double)value;
m_long = (long)m_real_double; 
m_ulong = (unsignedlong)m_real_double;

We use different optimization levels for C code (-o3) and C++ code (-o2). Can it cause any issue?


Viewing all articles
Browse latest Browse all 91752

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>