Page 1 of 1

Formula

Posted: Fri Mar 15, 2019 4:11 pm
by knothead1008
I'm working on a calculator of sorts. It is called Lace Calculator. What it is supposed to do is,
User inputs a fractional lace size, ie (1/8).
Then,
User inputs the diameter of the circle they're going to cut from in inches ie (12 inches round).
Then in the code it calculates the yield of lace that the user inputs from the above user inputs.

What I'd really like to do is include MM in that user inputs and yields. I would also, like to save it to a text file for more user manipulation.
I'm wondering if PI can be used in the MM calculations or not.
I'll also post the code once I have it all typed out.

Thanks for your time and reply.
Brian.

Code: Select all

50 DIM F$(35): DIM D(35)
60 FOR X = 1 TO 30
    70 READ F$(X), D(X)
80 NEXT X
100 INPUT "ENTER WIDTH OF LACE FRACTION ie(1/8)"; L$
110 IF L$ = " " THEN L$ = "1/16"
120 FOR X = 1 TO 30
    130 IF L$ = F$(X) THEN FL = X
140 NEXT X

200 INPUT "ENTER DIAMETER OF CIRCLE TO BE CUT IN INCHES"; C
210 IF C = 0 THEN C = 3
220 CLS: PI = 3.1416: DD = C: R = 0
250 PRINT TAB(40); "CIRCLE DIAMETER": PRINT
260 PRINT "WIDTH OF LACE";
270 PRINT TAB(20); C; TAB(32); C + 1; TAB(43); C + 2; TAB(53); C + 3; TAB(64); C + 4; TAB(75); C + 5

300 IF R > 9 THEN 420
310 PRINT: PRINT F$(FL);
320 PRINT TAB(7); D(FL); TAB(16);
330 FOR Y = 1 TO 6
    340 CD = C: TL = 0
    350 D = CD * PI
    360 CD = CD - (2 * D(FL))
    370 TL = TL + D
    380 IF CD > 1 THEN 350
    390 PRINT USING "  ###.## YD"; TL / 36;
400 C = C + 1: NEXT Y
410 R = R + 1: C = DD: FL = FL + 1: PRINT: GOTO 300
420 T$ = INKEY$: IF T$ = "C" OR T$ = "c" THEN 100 ELSE GOTO 420
' -------------- END CODE -------------------------------------------------

' ------------------ BEGIN DATA SETS ----
500 DATA "1/16",0.0625,5/64,0.0781,3/32,0.0938,7/64,0.1094,1/8,0.125,9/64,0.1406,5/32,0.1563,11/64,0.1719,3/16,0.1875,13/64,0.2031
510 DATA 1/2,.5,12.700,33/64,.5156,13.096,17/32,.5312,13.493,35/64,.5469,13.890,9/16,.5625,14.287,37/64,.5781,14.684,19/32,.5937,15.081,39/64,.6094,15.478,5/8,.625,15.875,41/64,.6406,16.271,21/32,.6562,16.668,43/64,.6719,17.065,11/16,.6875,17.462,45/64,.7031,17.859,23/32,.7187,18.256,47/64,.7344,18.653,3/4,.75,19.050,49/64,.7656,19.446,25/32,7812,19.843,51/64,.7969,20.240,13/16,.8125,20.637,53/64,.8281,21.034,27/32,.8437,21.431,55/64,.8594,21.828,7/8,.875,22.225,57/64,.8906,22.621,29/32,.9062,23.018,59/64,.9219,23.415,15/16,.9375,23.812,61/64,.9531,24.209,31/32,.9687,24.606
' ----------------- END DATA SETS --------

Re: Formula

Posted: Tue Mar 19, 2019 7:11 am
by burger2227
ATN can be used to define π in SINGLE or DOUBLE precision. The calculation cannot be used as a CONSTant.

Code: Select all

Pi = 4 * ATN(1)   'SINGLE precision
Pi# = 4 * ATN(1#) 'DOUBLE precision
PRINT Pi, Pi#  
The QB64 _PI function returns π as a _FLOAT value with an optional multiplier parameter.

Code: Select all

radius = 5
circlearea = _PI(radius ^ 2)
PRINT circlearea
https://www.qb64.org/wiki/ATN

Re: Formula

Posted: Fri Mar 22, 2019 12:13 pm
by knothead1008
So, pi would work the same in metric as it does with standard?