## Floating point equations to integer equations?

Electronics Computer Programming Q&A
LucidGuppy
Posts: 38
Joined: Tue Jun 01, 2004 1:01 am
Location: Deep 13
Contact:

### Floating point equations to integer equations?

So computers don't really like floating point. If you have an equation thats in scientific notation how do you convert it so that it works with integers? For simple equations I'm fine but it gets pretty hairy when the equation has big exponents and stuff like that. Can any point me in the direction to an aproach to convert equations to integer equations?
Why don't you give yourself a nice big round of applause!

CeaSaR
Posts: 1730
Joined: Sat Nov 08, 2003 1:01 am
Location: Phoenixville, PA USA
Contact:

### Re: Floating point equations to integer equations?

First thing that comes to mind is:
'to raise a number to a power use the carrat sign between the number to be raised and the power'. Ie: 2.45^20is 2.45 raised to the 20th power or 60718591.32 (that's as far as my handheld calc goes). At least that's the way QuickBasic does it.<p>Here's a sample:<p>1 COLOR 11, 5
CLS
PRINT : PRINT : PRINT : PRINT : PRINT
PRINT " BANDPASS BOX SPEAKER DESIGN PROGRAM"
PRINT : PRINT
INPUT " Fo="; FS
INPUT " Vas="; V
INPUT " Qts="; Q
2 INPUT " Low end cutoff="; FL
LET VF = (1.2 * Q) ^ 2 * V
LET A = FL / (FS / Q)
LET B = A + .95
LET FH = B * (FS / Q)
PRINT " LOW FREQUENCY CUTOFF="; FL; "Hz."
PRINT " HIGH FREQUENCY CUTOFF="; FH; "Hz."
INPUT " TRY ANOTHER FREQUENCY(1=Y,2=N)ENTER"; C
ON C GOTO 2, 3
3 PRINT
LET QT = A + .37
LET VB = V / (((QT / Q) ^ 2) - 1)
LET FB = QT * (FS / Q)
4 INPUT " CHOOSE DUCT SIZE BETWEEN 1 - 6 IN."; D
LET DA = (D / 2) ^ 2 * 3.14159
LET DL = ((2691 * DA) / (VB * (FB ^ 2))) - (.88 * SQR(DA))
LET VT = VF + VB
PRINT " DUCT IS"; DL; "IN. LONG"
INPUT " SATISFACTORY(1=Y,2=N)ENTER"; E
ON E GOTO 5, 4
5 CLS
PRINT : PRINT : PRINT : PRINT : PRINT : PRINT
PRINT " LOW FREQ. CUTOFF="; FL; "Hz."
PRINT " HIGH FREQ. CUTOFF="; FH; "Hz."
PRINT " FRONT BOX VOLUME="; VF; "CU. FT."
PRINT " REAR BOX VOLUME="; VB; "CU. FT."
PRINT " TOTAL BOX VOLUME="; VT; "CU. FT."
PRINT " FRONT BOX FREQ.="; FB; "Hz."
PRINT " DUCT SIZE="; D; "IN.DIAM. X"; DL; " IN. LONG"
INPUT " TRY ANOTHER DESIGN(1=Y,2=N)ENTER"; X
ON X GOTO 1, 6
6 CLS
PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT
PRINT " BASSY LISTENING!"
END<p>Have fun with it <p>CeaSaR
Hey, what do I know?

### Who is online

Users browsing this forum: No registered users and 4 guests