From: Marios K. <kou...@cs...> - 2011-10-04 09:25:36
|
I tried casting to "unsigned long int" and again I have the same problem. So it must be a printf problem... float f_num = 33000.0; printf("%d\n",(unsigned long int)f_num); On 10/4/11 12:08 PM, "Moritz Struebe" <Mor...@in...> wrote: >On 2011-10-04 10:29, Marios Koutroullos wrote: >> I found out that if I print the following float by casting it to int it >> prints correctly: >> float f = 32000.0 >> printf(" %d \n", (int)f); >> >> However if I try to print the following float I get negative: >> float f = 33000.0 >> printf(" %d \n", (int)f); >> >> >> >> How I can display float numbers greater than 33000.0 using msp430-gcc? >> > >This has nothing to do with msp430 but casting in C, integer-width and >how printf works (it it not Java!). You should grab a decent C-book (one >of the thicker ons) and read the chapter about casting, as it is likely >that you will run into problems at some other places, too. > >Cheers >Morty > > >-- >Dipl.-Ing. Moritz 'Morty' Struebe (Wissenschaftlicher Mitarbeiter) >Lehrstuhl für Informatik 4 (Verteilte Systeme und Betriebssysteme) >Friedrich-Alexander-Universität Erlangen-Nürnberg >Martensstr. 1 >91058 Erlangen > >Tel : +49 9131 85-25419 >Fax : +49 9131 85-28732 >eMail : st...@in... >WWW : http://www4.informatik.uni-erlangen.de/~morty > > > > >-------------------------------------------------------------------------- >---- >All the data continuously generated in your IT infrastructure contains a >definitive record of customers, application performance, security >threats, fraudulent activity and more. Splunk takes this data and makes >sense of it. Business sense. IT sense. Common sense. >http://p.sf.net/sfu/splunk-d2dcopy1_______________________________________ >________ >Contiki-developers mailing list >Con...@li... >https://lists.sourceforge.net/lists/listinfo/contiki-developers |