Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List of QB64 Constants?
#1
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
Reply
#2
A forum member from that little island country just off to the east of Ireland posted some, here: https://qb64phoenix.com/forum/showthread...ght=3.1415

Pete
Reply
#3
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?)
b = b + ...
Reply
#4
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
Fake News + Phony Politicians = Real Problems

Reply
#5
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
Reply
#6
QB64 doesn't have any defined CONST, unless you count the color const which you have to set with $COLOR.
Reply




Users browsing this thread: 1 Guest(s)