COSMIC Type Cast Problem
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2009-12-22 3:12 AM
Posted on December 22, 2009 at 12:12
COSMIC Type Cast Problem
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 6:06 AM
Posted on May 17, 2011 at 15:06
We have 2 issues during using COSMIC Compiler 4.3.1 16k Limit version and STVD 4.1.3, R-Link.
First, we don’t have functional value through using Local Variable, when we use as above it shows different value on long_var. void main(void) { long long_var = 0; float float_var = 0; long_var = 533485489; float_var = (float)long_var; while (1) { } }http://www.insem.co.kr/100201/1_local.gif
Second, Type Casting problem. long long_var = 533485489; float float_var = 0; void main(void) { float_var = (float)long_var; while (1) { } } It showed wrong value on float_var as it was inserted Type Casting after we declared global variable, however, it goes properly in main function as follows. long long_var; float float_var = 0; void main(void) { long_var = 533485489; float_var = (float)long_var; while (1) { } } We think it has a problem, isn’t it?Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 6:06 AM
Posted on May 17, 2011 at 15:06
Hi,
The setting Display Item from Decimal on Standard in debuger solved the problem. Regards Kris.Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 6:06 AM
Posted on May 17, 2011 at 15:06
also, when you work with local variables that are not actually used for anything, the compiler sometimes optimize them out: use globals or, at least, declare the locals volatile, to avoid this.
