QB64 Phoenix Edition
List of QB64 Constants? - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10)
+---- Thread: List of QB64 Constants? (/showthread.php?tid=348)



List of QB64 Constants? - dcromley - 05-05-2022

Is there a list of QB64 constants, like _PI=3.14..?
Also, 1/0 gives INF and -1/0 gives -INF.  Are there INF and -INF constants?
This code is just some experimenting (some garbage in the 2nd line of output - no problem).


Code: (Select All)
DefLng I
DefSng F
On Error GoTo zerr

Print _Pi
fhi = 1 / 0
flo = -1 / 0
Print "div by 0 - float:", fhi; flo
ihi = 1 / 0
ilo = -1 / 0
Print "div by 0 - long integer:", ihi, ilo

Print "Sqr(-1)= "; Sqr(-1)

zerr:
Print Chr$(13) + "Err"; Err; "in line"; _ErrorLine
End



RE: List of QB64 Constants? - Pete - 05-05-2022

A forum member from that little island country just off to the east of Ireland posted some, here: https://staging.qb64phoenix.com/showthread.php?tid=325&highlight=3.1415

Pete


RE: List of QB64 Constants? - bplus - 05-05-2022

I think Inf and -Inf are to indicate over flow errors without erroring out your program.

There is also Exp(x) for e^x so e = Exp(1)

i for imaginary sq(-1) is not considered by QB64 but someone is sure to have library for complex numbers.

Maybe Sprezzo! (Doesn't it look better with an ! at the end?)


RE: List of QB64 Constants? - Pete - 05-05-2022

INF (It's not funny?) Maybe change that to INFP, (It's not... possible.)

Anyway, I forgot dc also asked about that INF, -IFN stuff. This was not in QBasic, but because QB64 is a C/C++ translator, We see it when we cause a severe math error as trying to divide by zero, or better put...

"The C++ infinity is written as "INF" and it accrues in the outcome of dividing a positive numeric value by a null value or calculating a numeric value that is greater than the larger number of our system that can be represented in 64 bits."

So INF stands for infinity. Don't even try to define that as a constant.

Pete


RE: List of QB64 Constants? - dcromley - 05-05-2022

You guys crack me up!
@pete    What I was interested in is constants defined by QB64 so I wouldn't have to define them.
@Sprezzo LOL!
@bplus  I like the "without erroring out" approach.
@pete    FWIW, run the code (I don't think it's worth too much)


Code: (Select All)
DefStr S
' const INFP = 1/0, INFM = -1/0 ' NG
Dim INFP, INFM
INFP = 1 / 0 ' + infinity
INFM = -1 / 0 ' - infinity

Print "Is 1 < INFP ?  "; sTF(1 < INFP)
Print "Is 1 > INFP ?  "; sTF(1 > INFP)
Print "Is 1 < INFM ?  "; sTF(1 < INFM)
Print "Is 1 > INFM ?  "; sTF(1 > INFM)
Print "Is INFM < INFP ?  "; sTF(INFM < INFP)
Print "Is INFM > INFP ?  "; sTF(INFM > INFP)
Print "Is 1/0 = INFP ?  "; sTF(1 / 0 = INFP)  

Function sTF (x)
  If x Then sTF = "True" Else sTF = "False"
End Function



RE: List of QB64 Constants? - SMcNeill - 05-06-2022

QB64 doesn't have any defined CONST, unless you count the color const which you have to set with $COLOR.