Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Floating point math in PBASIC (http://www.chiefdelphi.com/forums/showthread.php?t=41032)

John Gutmann 25-12-2005 23:25

Floating point math in PBASIC
 
I was wondering if anyone can help me with how to do floating point math on a Basic Stamp 2? I know your not directly able to do it on them but is there anyway to get around it?

Mike 26-12-2005 12:37

Re: Floating point math in PBASIC
 
Multiply everything by 1000.

1.759 becomes 1759
3.14 becomes 3140
etc.

Alan Anderson 26-12-2005 20:07

Re: Floating point math in PBASIC
 
Quote:

Originally Posted by sparksandtabs
I was wondering if anyone can help me with how to do floating point math on a Basic Stamp 2?

Quote:

Originally Posted by Mike
Multiply everything by 1000.

That'll let you represent fractional values, but it's fixed point, not floating point.

To do true floating point, you need to use a variable scaling factor rather than just picking e.g. 1000 in advance, and you have to keep track of the scaling when multiplying and dividing. (When you add or subtract, you need to equalize the scaling factors first.)


All times are GMT -5. The time now is 04:32.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi