jackchaos Posted October 27, 2006 Report Share Posted October 27, 2006 Is it possible to cast from Char to Int?Like: unsigned char a = 5; unsigned int b = 1000; int c = b * (int)a; When I try to do such a thing I get the following error when running make: Compiling main.c Processor: 18F452 ================================================ Linking project error: missing definition for symbol "__mulint" ERROR! Quote Link to comment Share on other sites More sharing options...
jackchaos Posted October 27, 2006 Author Report Share Posted October 27, 2006 Never mind, I found this document.http://www.midibox.org/dokuwiki/doku.php?id=stryd_one_codeblocksWhich introduces me to Code:Blocks and I believe the included LIB is what's helping me.You guys are great. Quote Link to comment Share on other sites More sharing options...
DavidBanner Posted October 27, 2006 Report Share Posted October 27, 2006 why would you want to store an int in a var char? Quote Link to comment Share on other sites More sharing options...
audiocommander Posted October 27, 2006 Report Share Posted October 27, 2006 http://www.midibox.org/dokuwiki/doku.php?id=c_tips_and_tricks_for_pic_programmingsee Arithmetic Calculations ;) Quote Link to comment Share on other sites More sharing options...
jackchaos Posted October 27, 2006 Author Report Share Posted October 27, 2006 why would you want to store an int in a var char?I have a lookup table filled with unsigned chars that define the config and behavior of each and every pot. One of the items is a refresh interval that later gets multiplied by 500 (this may change later).This is the only way I can see how to do it... and yes, I'm doing a multiplication the bad way (a = b*c).http://www.midibox.org/dokuwiki/doku.php?id=c_tips_and_tricks_for_pic_programmingsee Arithmetic CalculationsI'm at work right now, but from what I see in this document. If I change my 500 (above) to 512and do a bit shift like so:a = 2 << 9; // a is 1024ora = 5 << 9; // a is 2560This would be the equivalent of:a = 2 * 512;or a = 5 * 512;If this is true, I've solved that problem and I can make the changes when I get home.Thanks again!( audiocommander, yes. I meant 'a = 2 * 512;', It's corrected above. Thanks. ) Quote Link to comment Share on other sites More sharing options...
audiocommander Posted October 27, 2006 Report Share Posted October 27, 2006 I'm sure you mean a = 2 * 512, then it's correct and you'll save a lot of codespace and calculating power this way ;)Cheers!Michael Quote Link to comment Share on other sites More sharing options...
DavidBanner Posted October 27, 2006 Report Share Posted October 27, 2006 out of sheer morbid curiosity - why store the var in a char and not an int? Quote Link to comment Share on other sites More sharing options...
jackchaos Posted October 27, 2006 Author Report Share Posted October 27, 2006 unsigned char two_dimensional_array[NUM_POTS][NUM_OPTIONS]The array can only hold one value type. I'm storing all my config here and every value is a char.I want the option to scale all the update intervals so the interval is later multiplied by another number which is higher than 255. Quote Link to comment Share on other sites More sharing options...
DavidBanner Posted October 27, 2006 Report Share Posted October 27, 2006 cheers - that makes sense to me now..... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.