piclist 2002\02\22\173102a >
Thread: MPLAB floating point in C
www.piclist.com/techref/microchip/languages.htm?key=mplab
picon face BY : wouter van ooijen & floortje hanneman email (remove spam text)



> That's probably the problem.  Dunno about Bytecraft, but the compiler
> probably isn't quite intiutive enough to know that you want to perform an
> operation with two longs and get a float result.  It's probably going to
> do a long mult, then try to map the result into a float variable...  the
> results aren't going to be pretty, I've found.

But that is exactly what the compiler is required to do, if it implements C.
If you want a fractional result, cast one of the operands to float (or
multiply by 1.0)

((float)A)/B
or
1.0*A/B

etc.

Wouter van Ooijen

--
Van Ooijen Technische Informatica: http://www.voti.nl
Jal compiler, Wisp programmer, WLoader bootloader, PICs kopen

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


<022501c1bbb2$263d2a00$0500a8c0@home> 7bit

See also: www.piclist.com/techref/microchip/languages.htm?key=mplab
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) MPLAB floating point in C

month overview.

new search...