From: Carlo A. B. <cb...@si...> - 2010-08-12 15:43:09
|
Hello Nahuel, I was able to print floating numbers on the Tmote Sky. Here is how I did it: #include <math.h> int a1=7, a2=8; float b1 = (float) a1*1.000; float b2 = (float) a2*1.000; float f = b1 / b2; printf("%d / %d = %ld.%03u\n", a1, a2, (long)f, (unsigned)((f-floor(f))*1000)); You also need to hack on your makefile to enable the compilation of the math library. My solution is as follows: CUSTOM_RULE_LINK=1 %.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a $(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ -lm Best Regards, Carlo Il 10/08/2010 17:19, Marek Bykowski ha scritto: > Hello, > > There is no Floating Point Unit on the most of embedded platforms. > The compiler version under Contiki doesn't support float formats. > > Grep through Contiki directories - there is almost no float > definitions in the files. Try to avoid it as much as possible. Use > fixed point arithmetic if needed. > > Cheers, > Marek > > On 10 August 2010 15:11, Nahuel Marisi <nah...@gm... > <mailto:nah...@gm...>> wrote: > > I'm having a simple, yet weird problem. > > Every time I try to print floating point numbers using the format > specifier %f I get an f literally printed. > > for example, > > printf("floating point number: %f\n",131.231); > > prints: floating pointer number f > > Basically I'm using the energest module and use %li to print its > values, but when I try to convert it to energy use (dividing by > 8192 and > multiplying by 3 and 20 ) if I printed using long ints I just see > 0. The difference prints fine > > > > any ideas? > > Thanks, > Nahuel > ------------------------------------------------------------------------------ > This SF.net email is sponsored by > > Make an app they can't live without > Enter the BlackBerry Developer Challenge > http://p.sf.net/sfu/RIM-dev2dev > _______________________________________________ > Contiki-developers mailing list > Con...@li... > <mailto:Con...@li...> > https://lists.sourceforge.net/lists/listinfo/contiki-developers > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by > > Make an app they can't live without > Enter the BlackBerry Developer Challenge > http://p.sf.net/sfu/RIM-dev2dev > > > _______________________________________________ > Contiki-developers mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/contiki-developers > |