You are a BASIC bitch, so type-in and share your BASIC listings here. Any and all BASIC dialects are welcome.

  • Zaphod42@lemmy.sdf.org
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    Originally coded for a Sharp PC-1251. Basically my “Hello World” in every programming language I try:

    10: INPUT "GEWICHT IN KG" , M
    20: INPUT "GROESSE IN M" ,L
    30: B=M/L^2
    40: PRINT "BMI = ";B
    

    I ported this to LF-BASIC https://github.com/LiquidFox1776/LF-BASIC, a BASIC-interpreter written in Python:

    10 LET M=0
    20 LET L=0
    30 LET B=0
    40 INPUT "GEWICHT IN KG "; M
    50 INPUT "GROESSE IN CM "; L
    60 LET L=L/100
    70 LET B=M/L^2
    80 PRINT "BMI = "; B
    

    Then I started using PDP-8-Emulation and TSS-8:

    10 LET M=0
    20 LET L=0
    30 LET B=0
    35 PRINT "WEIGHT IN KG.G:"
    40 INPUT M
    45 PRINT "HEIGHT IN CM:"
    50 INPUT L
    60 LET L=L/100
    70 LET B=M/L^2
    75 PRINT "YOUR BMI IS:"
    80 PRINT B
    90 END
    
  • over_clox@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    1 year ago

    RapidQ integer rounding was totally broken, so I wrote this…

    
    ABSVal# = ABS(Value#): SGNVal& = SGN(Value#)
    	FIXVal& = FIX(ABSVal#): FRACVal# = FRAC(ABSVal#)
    	AddVal& = (((FRACVal# = .5) AND FIXVal&) OR (FRACVal# > .5)) AND 1
    	FIXVal& += AddVal&: IF SGNVal& = -1 THEN FIXVal& = -FIXVal&
    	RQRoundFix = FIXVal&
    END FUNCTION```
    • jadero@lemmy.sdf.org
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      Are you sure that rounding was broken? Many systems use “Gaussian” or “banker’s” rounding to reduce accumulation of rounding errors. Instead of always rounding to the next larger absolute value at .5, they round to the nearest even number. Although it introduces a bias toward even numbers in the result set, it reduces accumulation of error when .5 is as likely as as any other fraction and odd/even are equally likely in the source.

      I was taught “banker’s” rounding in school (graduated 1974) and have had to implement it a few times to reduce error accumulation.

      If you are looking for a rabbit hole, Wikipedia has a pretty comprehensive article, including an example of how the wrong choice of rounding algorithm led to massive problems at the Vancouver Stock Exchange (Canada).

  • Ubuntu Peronista@lemmy.sdf.orgOP
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    1 year ago
    1  REM TEST YOUR INPUT AND THEN
    10 PRINT "DO YOU EAT YOUR BOUGHS??"
    20 INPUT X
    30 IF X="YES" THEN PRINT "YOU PIG!.": END
    40 IF X="NO" THEN PRINT "WHAT ARE YOU WAITING FOR TO TRY?"
    50 END
    
  • Ubuntu Peronista@lemmy.sdf.orgOP
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago
    10 : CLEAR : PAUSE “Mini Moon Age Calculator “
    20 : W=694098 : X=29.53 : Z=365.25 : JN=2460202.6 : REM Julian date for last moon on 25/9/2023 at 2:39am
    30 : INPUT “DAY:” ; D , “MONTH:” ; M , “YEAR:” ; Y
    40 : IF M<=2 LET Y=Y-1 : M=M+12
    50 : A=INT(Y/100) : B=INT(A/4) : C=2-A+B : E=INT(Z * (Y+4716))
    60 : F=INT(30.6001 * (M+1)) : JD=C+D+E+F-1524.5 : DS=JD-JN
    70 : S=(DS/X-INT(DS/X)) * X : S=INT(S+.5)
    80 : PRINT “Age of Moon “ ; USING “###.# “ ; S ; “_days” : END
    

    Stay SHARP!

  • Ubuntu Peronista@lemmy.sdf.orgOP
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Darthmouth GRAFIX.BAS!

    100 DEF FNF(X)=SIN(X)
    105 DEF FNG(X)=LOG(X)/LOG(10)
    110 DEF FNR(X)=INT(X+.5)
    120 DEF FNX(X)=INT(100*X+.5)/100
    130 READ A,B,S
    140 READ C,D,N
    150 IF N<=50 THEN 180
    160 PRINT "ONLY 50 SUBDIVISIONS"
    170 STOP
    175 :
    180 H=(D-C)/N
    190 PRINT ""Y-AXIS FROM ";C;" TO ";D;
    195 PRINT " IN INCREMENTS OF ";H
    200 PRINT
    210 PRINT TAB(8);"'";
    220 FOR I=1 TO N-1
    230    PRINT "-";
    240 NEXT I
    250 PRINT "'"
    255 :
    260 FOR X=A TO B STEP S
    270    Y=FNF(X)
    272    Y1=8+FNR((Y-C)/H)
    274    Y=FNG(X)
    276    Y2=8+FNR((Y-C)/H)
    278    PRINT FNX(X);
    280    IF Y2
  • Ubuntu Peronista@lemmy.sdf.orgOP
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    This a Sharp BASIC suffler for the 40 spanish card deck, for truco and other games.

    10:REM BARAJADOR MAZO DE 40 CARTAS ESPANOLAS,SHARP PC-1360
    20:WAIT 0: CLS : CLEAR
    30:DIM A$(41)*20,S$(0)*32,P$(0)*65
    40:C=0:S$(0)="Basto   Espada  Oro     Copas"
    50:P$(0)="As   Dos  Tres CuatroCincoSeis SieteSota CaballoRey"
    60:FOR S=1 TO 4
    70:FOR N=1 TO 10
    80:C=C+1
    90:A$(C)= MID$ (P$(0),(N*5)-4,5)+" de "+ MID$ (S$(0),(S*8)-5,0)
    100:NEXT N: NEXT S
    110:FOR C=41 TO 2 STEP - 1:A= RND (40)+1:A$(C)=A$(A):A$(A)=A$(C-1): NEXT C: BEEP 1: WAIT
    120:FOR C=1 TO 40: PRINT SRT$ (C);":";A$(C): NEXT C