BCX Run-time Mathematical Procedures

Most BCX mathematical functions return DOUBLE floating point values and expect DOUBLE floating point values for their arguments.

BCX LDOUBLE functions return LDOUBLE floating point values and expect LDOUBLE floating point values for their arguments.

PI mathematical constant

Purpose: PI is a case-insensitive double precision numeric literal with a value of 3.141592653589793.

Programs will need to be updated where a PI identifier has been used. That means removing your use of the PI identifier, regardless of case or data type. If you insist on having your definition of PI, you will need to change its name to something else like myPI.

DEGTORAD function

Purpose: DEGTORAD converts angular units from degrees to radians.


Syntax:

 AngleInRadians = DEGTORAD(AngleInDegrees AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    AngleInRadians A radian angle.

Parameters:

  • Data type: DOUBLE
    AngleInDegrees The degree angle.

Example:


 $BCXVERSION "8.0.4"
 
 DIM AS DOUBLE DegreeAngle
 DIM AS DOUBLE RadianAngle
 DIM AS DOUBLE SineOfAngle
 DIM AS STRING TheAnswer
     
 DegreeAngle = 36.0
    
 RadianAngle = DEGTORAD(DegreeAngle)
    
 SineOfAngle = SIN(RadianAngle)
    
 SPRINT TheAnswer, "The sine of", STR$(DegreeAngle), " degrees is", SineOfAngle
    
 PRINT TheAnswer

Result:


 The sine of 36 degrees is 0.587785252292464

RADTODEG function

Purpose: RADTODEG converts angular units from radians to degrees.


Syntax:

 AngleInDegrees = RADTODEG(AngleInRadians AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    AngleInDegrees A degree angle.

Parameters:

  • Data type: DOUBLE
    AngleInRadians The radian angle.

Example:


 $BCXVERSION "8.0.4"
 
 DIM AS DOUBLE DegreeAngle
 DIM AS DOUBLE RadianAngle
 DIM AS DOUBLE SineOfAngle
 DIM AS STRING TheAnswer
  
 DegreeAngle = 36.0
  
 RadianAngle = DEGTORAD(DegreeAngle)
  
 SineOfAngle = SIN(RadianAngle)
  
 SPRINT TheAnswer, "The angle of", STR$(DegreeAngle), " degrees has a sine trigonometric ratio of", SineOfAngle
  
 PRINT TheAnswer
  
 RadianAngle = ASIN(SineOfAngle)
  
 DegreeAngle = RADTODEG(RadianAngle)
  
 SPRINT TheAnswer, "The sine trigonometric ratio of", SineOfAngle, " corresponds to an angle of", DegreeAngle, " degrees."
  
 PRINT TheAnswer

Result:


 The angle of 36 degrees has a sine trigonometric ratio of 0.587785252292464
 The sine trigonometric ratio of 0.587785252292464 corresponds to an angle of 35.9999999999994 degrees.

Trigonometric functions

Trigonometric functions are used to obtain an angle's trigonometric ratio from an angle.

All trigonometric functions use radians, not degrees, for their arguments and return values.

The inverse trigonometric functions return radian values.

SIN function

Purpose: SIN returns the DOUBLE sine trigonometric ratio of a radian value angle.


Syntax:

 SineOfAngle = SIN(RadianAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    SineOfAngle The sine of an angle.

Parameters:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Example:


 DIM AS DOUBLE RadFromDeg
 DIM AS DOUBLE DegreeAngle
 DIM AS DOUBLE RadianAngle
 DIM AS DOUBLE SineOfAngle
 DIM AS STRING TheAnswer

 RadFromDeg = (PI / 180.0)
  
 DegreeAngle = 36.0
  
 RadianAngle = DegreeAngle * RadFromDeg
  
 SineOfAngle = SIN(RadianAngle)
  
 SPRINT TheAnswer, "The sine of", STR$(DegreeAngle), " degrees is", SineOfAngle
  
 PRINT TheAnswer
  

Result:


 The sine of 36 degrees is 0.587785252292473

SINL function

Purpose: SINL returns the LDOUBLE sine trigonometric ratio of an angle.


Syntax:

 SineOfAngle = SINL(RadianAngle AS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    SineOfAngle The sine of an angle.

Parameters:

  • Data type: LDOUBLE
    RadianAngle A radian angle.

Example:


 DIM LDbl_PI AS LDOUBLE
 DIM RadFromDeg AS LDOUBLE
 DIM DegreeAngle AS LDOUBLE
 DIM RadianAngle AS LDOUBLE
 DIM SineOfAngle AS LDOUBLE
 DIM AS STRING TheAnswer
   
 LDbl_PI = (4.0 * ATNL(1.0)) ' 1.0 is radians not degrees. 
 
 RadFromDeg = (LDbl_PI / 180.0)
   
 DegreeAngle = 36.0
   
 RadianAngle = DegreeAngle * RadFromDeg
   
 SineOfAngle = SINL(RadianAngle)
   
 SPRINT TheAnswer, "The sine of", STR$(DegreeAngle), " degrees is", SineOfAngle
   
 PRINT TheAnswer

Result:


 The sine of 36 degrees is 0.5877852522924731292

COS function

Purpose: COS returns the DOUBLE cosine trigonometric ratio of an angle.


Syntax:

 CosineOfAngle = COS(RadianAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    CosineOfAngle The cosine of an angle.

Parameters:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Example:


 DIM AS DOUBLE RadFromDeg
 DIM AS DOUBLE DegreeAngle
 DIM AS DOUBLE RadianAngle
 DIM AS DOUBLE CosineOfAngle
 DIM AS STRING TheAnswer

 RadFromDeg = (PI / 180.0)
  
 DegreeAngle = 36.0
  
 RadianAngle = DegreeAngle * RadFromDeg
  
 CosineOfAngle = COS(RadianAngle)
  
 SPRINT TheAnswer, "The cosine of", STR$(DegreeAngle), " degrees is", CosineOfAngle
  
 PRINT TheAnswer

Result:


 The cosine of 36 degrees is 0.809016994374947

COSL function

Purpose: COSL returns the LDOUBLE cosine trigonometric ratio of an angle.


Syntax:

 CosineOfAngle = COSL(RadianAngleAS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    CosineOfAngle The cosine of an angle.

Parameters:

  • Data type: LDOUBLE
    RadianAngle A radian angle.

Example:


 DIM LDbl_PI AS LDOUBLE
 DIM RadFromDeg AS LDOUBLE
 DIM DegreeAngle AS LDOUBLE
 DIM RadianAngle AS LDOUBLE
 DIM CosineOfAngle AS LDOUBLE
 DIM AS STRING TheAnswer
   
 LDbl_PI = (4.0 * ATNL(1.0)) ' 1.0 is radians not degrees. 
 
 RadFromDeg = (LDbl_PI / 180.0)
   
 DegreeAngle = 36.0
   
 RadianAngle = DegreeAngle * RadFromDeg
   
 CosineOfAngle = COSL(RadianAngle)
   
 SPRINT TheAnswer, "The cosine of", STR$(DegreeAngle), " degrees is", CosineOfAngle
   
 PRINT TheAnswer

Result:


 The cosine of 36 degrees is 0.8090169943749474241
 

TAN function

Purpose: TAN returns the DOUBLE tangent trigonometric ratio of an angle.


Syntax:

 TangentOfAngle = TAN(RadianAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    TangentOfAngle The tangent of an angle.

Parameters:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Example:


 DIM AS DOUBLE RadFromDeg
 DIM AS DOUBLE DegreeAngle
 DIM AS DOUBLE RadianAngle
 DIM AS DOUBLE TangentOfAngle
 DIM AS STRING TheAnswer

 RadFromDeg = (PI / 180.0)
   
 DegreeAngle = 36.0
   
 RadianAngle = DegreeAngle * RadFromDeg
   
 TangentOfAngle = TAN(RadianAngle)
   
 SPRINT TheAnswer, "The tangent of", STR$(DegreeAngle), " degrees is", TangentOfAngle
   
 PRINT TheAnswer
 

Result:


 The tangent of 36 degrees is 0.726542528005361

TANL function

Purpose: TANL returns the LDOUBLE tangent trigonometric ratio of an angle.


Syntax:

 TangentOfAngle = TANL(RadianAngle AS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    TangentOfAngle The tangent of an angle.

Parameters:

  • Data type: LDOUBLE
    RadianAngle A radian angle.

Example:


 DIM LDbl_PI AS LDOUBLE
 DIM RadFromDeg AS LDOUBLE
 DIM DegreeAngle AS LDOUBLE
 DIM RadianAngle AS LDOUBLE
 DIM TangentOfAngle AS LDOUBLE
 DIM AS STRING TheAnswer
    
 LDbl_PI = (4.0 * ATNL(1.0)) ' 1.0 is radians not degrees. 
 
 RadFromDeg = (LDbl_PI / 180.0)
    
 DegreeAngle = 36.0
    
 RadianAngle = DegreeAngle * RadFromDeg
    
 TangentOfAngle = TANL(RadianAngle)
    
 SPRINT TheAnswer, "The tangent of", STR$(DegreeAngle), " degrees is", TangentOfAngle
    
 PRINT TheAnswer

Result:


 The tangent of 36 degrees is 0.7265425280053608859

Inverse Trigonometric functions

Inverse trigonometric functions are used to obtain an angle from an angle's trigonometric ratio.

ASIN function

Purpose: ASIN returns the DOUBLE radian angle of a sine trigonometric ratio.


Syntax:

 RadianAngle = ASIN(SineOfAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Parameters:

  • Data type: DOUBLE
    SineOfAngle The sine of an angle.

Example:


 DIM AS DOUBLE RadFromDeg
 DIM AS DOUBLE DegFromRad
 DIM AS DOUBLE DegreeAngle
 DIM AS DOUBLE RadianAngle
 DIM AS DOUBLE SineOfAngle
 DIM AS STRING TheAnswer

 DegFromRad# = (180.0 / PI)
 
 RadFromDeg# = (PI / 180.0)
 
 DegreeAngle# = 36.0
 
 RadianAngle# = DegreeAngle * RadFromDeg
 
 SineOfAngle# = SIN(RadianAngle)
 
 SPRINT TheAnswer, "The angle of", STR$(DegreeAngle), " degrees has a sine trigonometric ratio of", SineOfAngle
 
 PRINT TheAnswer
 
 RadianAngle = ASIN(SineOfAngle)
 
 DegreeAngle# = RadianAngle * DegFromRad
 
 SPRINT TheAnswer, "The sine trigonometric ratio of", SineOfAngle, " corresponds to an angle of", DegreeAngle, " degrees."
 
 PRINT TheAnswer

Result:


 The angle of 36 degrees has a sine trigonometric ratio of 0.587785252292473
 The sine trigonometric ratio of 0.587785252292473 corresponds to an angle of 36 degrees.

ASINL function

Purpose: ASINL returns the LDOUBLE radian angle of a sine trigonometric ratio.


Syntax:

 RadianAngle = ASINL(SineOfAngle AS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    RadianAngle A radian angle.

Parameters:

  • Data type: LDOUBLE
    SineOfAngle The sine of an angle

Example:


 DIM LDbl_PI AS LDOUBLE
 DIM RadFromDeg AS LDOUBLE
 DIM DegFromRad AS LDOUBLE
 DIM DegreeAngle AS LDOUBLE
 DIM RadianAngle AS LDOUBLE
 DIM SineOfAngle AS LDOUBLE
 DIM AS STRING TheAnswer
  
 LDbl_PI = (4.0 * ATNL(1.0)) ' 1.0 is radians not degrees. 
 
 DegFromRad = (180.0 / LDbl_PI)
  
 RadFromDeg = (LDbl_PI / 180.0)
  
 DegreeAngle = 36.0
  
 RadianAngle = DegreeAngle * RadFromDeg
  
 SineOfAngle = SINL(RadianAngle)
  
 SPRINT TheAnswer, "The angle of", STR$(DegreeAngle), " degrees has a sine trigonometric ratio of", SineOfAngle
  
 PRINT TheAnswer
  
 RadianAngle = ASINL(SineOfAngle)
  
 DegreeAngle = RadianAngle * DegFromRad
  
 SPRINT TheAnswer, "The sine trigonometric ratio of", SineOfAngle, " corresponds to an angle of", DegreeAngle, " degrees."
  
 PRINT TheAnswer

Result:


 The angle of 36 degrees has a sine trigonometric ratio of 0.5877852522924731292
 The sine trigonometric ratio of 0.5877852522924731292 corresponds to an angle of 36 degrees.

ACOS function

Purpose: ACOS returns the DOUBLE radian value angle of a cosine trigonometric ratio.


Syntax:

 RadianAngle# = ACOS(CosineOfAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Parameters:

  • Data type: DOUBLE
    CosineOfAngle The cosine of an angle

Example:


 DIM AS DOUBLE RadFromDeg
 DIM AS DOUBLE DegFromRad
 DIM AS DOUBLE DegreeAngle
 DIM AS DOUBLE RadianAngle
 DIM AS DOUBLE CosineOfAngle
 DIM AS STRING TheAnswer

 DegFromRad = (180.0 / PI)
 
 RadFromDeg = (PI / 180.0)
 
 DegreeAngle = 36.0
 
 RadianAngle = DegreeAngle * RadFromDeg
 
 CosineOfAngle = COS(RadianAngle)
 
 SPRINT TheAnswer, "The angle of", STR$(DegreeAngle), " degrees has a cosine trigonometric ratio of", CosineOfAngle
 
 PRINT TheAnswer
 
 RadianAngle = ACOS(CosineOfAngle)
 
 DegreeAngle = RadianAngle * DegFromRad
 
 SPRINT TheAnswer, "The cosine trigonometric ratio of", CosineOfAngle, " corresponds to an angle of", DegreeAngle, " degrees."
 
 PRINT TheAnswer

Result:


 The angle of 36 degrees has a cosine trigonometric ratio of 0.809016994374947
 The cosine trigonometric ratio of 0.809016994374947 corresponds to an angle of 36 degrees.

ACOSL function

Purpose: ACOSL returns the LDOUBLE precision value of the radian angle of a cosine trigonometric ratio.


Syntax:

 RadianAngle = ACOSL(CosineOfAngle AS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    RadianAngle A radian angle.

Parameters:

  • Data type: LDOUBLE
    CosineOfAngle The cosine of an angle.

Example:


 DIM LDbl_PI AS LDOUBLE
 DIM RadFromDeg AS LDOUBLE
 DIM DegFromRad AS LDOUBLE
 DIM DegreeAngle AS LDOUBLE
 DIM RadianAngle AS LDOUBLE
 DIM CosineOfAngle AS LDOUBLE
 DIM AS STRING TheAnswer
  
 LDbl_PI = (4.0 * ATNL(1.0)) ' 1.0 is radians not degrees. 
 
 DegFromRad = (180.0 / LDbl_PI)
  
 RadFromDeg = (LDbl_PI / 180.0)
  
 DegreeAngle = 36.0
  
 RadianAngle = DegreeAngle * RadFromDeg
  
 CosineOfAngle = COSL(RadianAngle)
  
 SPRINT TheAnswer, "The angle of", STR$(DegreeAngle), " degrees has a cosine trigonometric ratio of", CosineOfAngle
  
 PRINT TheAnswer
  
 RadianAngle = ACOSL(CosineOfAngle)
  
 DegreeAngle = RadianAngle * DegFromRad
  
 SPRINT TheAnswer, "The cosine trigonometric ratio of", CosineOfAngle, " corresponds to an angle of", DegreeAngle, " degrees."
  
 PRINT TheAnswer

Result:


 The angle of 36 degrees has a cosine trigonometric ratio of 0.8090169943749474241
 The cosine trigonometric ratio of 0.8090169943749474241 corresponds to an angle of 36 degrees.

ATN function

Purpose: ATN returns the DOUBLE radian value angle of a tangent trigonometric ratio.


Syntax:

 RadianAngle = ATN(TangentOfAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Parameters:

  • Data type: DOUBLE
    TangentOfAngle The tangent of an angle

Example:


 DIM AS DOUBLE RadFromDeg
 DIM AS DOUBLE DegFromRad
 DIM AS DOUBLE DegreeAngle
 DIM AS DOUBLE RadianAngle
 DIM AS DOUBLE TangentOfAngle
 DIM AS STRING TheAnswer

 DegFromRad = (180.0 / PI)
 
 RadFromDeg = (PI / 180.0)
 
 DegreeAngle = 36.0
 
 RadianAngle = DegreeAngle * RadFromDeg
 
 TangentOfAngle = TAN(RadianAngle)
 
 SPRINT TheAnswer, "The angle of", STR$(DegreeAngle), " degrees has a tangent trigonometric ratio of", TangentOfAngle
 
 PRINT TheAnswer
 
 RadianAngle = ATN(TangentOfAngle)
 
 DegreeAngle = RadianAngle * DegFromRad
 
 SPRINT TheAnswer, "The tangent trigonometric ratio of", TangentOfAngle, " corresponds to an angle of", DegreeAngle, " degrees."
 
 PRINT TheAnswer

Result:


 The angle of 36 degrees has a tangent trigonometric ratio of 0.726542528005361 
The tangent trigonometric ratio of 0.726542528005361 corresponds to an angle of 36 degrees.

ATNL function

Purpose: ATNL returns the LDOUBLE precision value of the radian angle of a tangent trigonometric ratio.


Syntax:

 RadianAngle = ATNL(TangentOfAngle AS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    RadianAngle A radian angle.

Parameters:

  • Data type: LDOUBLE
    TangentOfAngle The tangent of an angle.

Example 1:


 DIM LDbl_PI AS LDOUBLE
 DIM RadFromDeg AS LDOUBLE
 DIM DegFromRad AS LDOUBLE
 DIM DegreeAngle AS LDOUBLE
 DIM RadianAngle AS LDOUBLE
 DIM TangentOfAngle AS LDOUBLE
 DIM AS STRING TheAnswer
   
 LDbl_PI = (4.0 * ATNL(1.0)) ' 1.0 is radians not degrees. 
  
 DegFromRad = (180.0 / LDbl_PI)
   
 RadFromDeg = (LDbl_PI / 180.0)
   
 DegreeAngle = 36.0
   
 RadianAngle = DegreeAngle * RadFromDeg
   
 TangentOfAngle = TANL(RadianAngle)
   
 SPRINT TheAnswer, "The angle of", STR$(DegreeAngle), " degrees has a tangent trigonometric ratio of", TangentOfAngle
   
 PRINT TheAnswer
   
 RadianAngle = ATNL(TangentOfAngle)
   
 DegreeAngle = RadianAngle * DegFromRad
   
 SPRINT TheAnswer, "The tangent trigonometric ratio of", TangentOfAngle, " corresponds to an angle of", DegreeAngle, " degrees."
   
 PRINT TheAnswer

Result:


 The angle of 36 degrees has a tangent trigonometric ratio of 0.7265425280053608859
 The tangent trigonometric ratio of 0.7265425280053608859 corresponds to an angle of 36 degrees.

Example 2:


 DIM DBL_Pi AS DOUBLE
 DIM LDBL_Pi AS LDOUBLE
 DBL_Pi = 4.0 * ATAN(1.0)
 LDBL_Pi = 4.0 * ATANL(1.0)
 PRINT "DOUBLE Pi  =", DBL_Pi
 PRINT "LDOUBLE Pi =", LDBL_Pi
 PAUSE

Result:


 DOUBLE Pi  = 3.14159265358979
 LDOUBLE Pi = 3.141592653589793239

 Press any key to continue . . .

Hyperbolic Trigonometric functions

SINH function

Purpose: SINH returns the DOUBLE hyperbolic sine trigonometric ratio of a radian value angle.


Syntax:

 HypeSineOfAngle = SINH(RadianAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    HypeSineOfAngle The hyperbolic sine of an angle

Parameters:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Example:


 DIM HalfPi AS DOUBLE
 DIM DBLSinh AS DOUBLE
 
 HalfPi = 2.0 * ATAN(1.0)
 DBLSinh = SINH(HalfPi)
 PRINT DBLSinh

Result:


 2.30129890230729

COSH function

Purpose: COSH returns the DOUBLE hyperbolic cosine trigonometric ratio of an angle.


Syntax:

 HypeCosineOfAngle = COSH(RadianAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    HypeCosineOfAngle The hyperbolic cosine of an angle

Parameters:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Example:


 DIM HalfPi AS DOUBLE
 DIM DBLCosh AS DOUBLE
 
 HalfPi = 2.0 * ATAN(1.0)
 DBLCosh = COSH(HalfPi)
 PRINT DBLCosh

Result:


 2.50917847865806

TANH function

Purpose: TANH returns the DOUBLE tangent trigonometric ratio of an angle.


Syntax:

 HypeTangentOfAngle = TANH(RadianAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    HypeTangentOfAngle The hyperbolic tangent of an angle.

Parameters:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Example:


 DIM QrtrPi AS DOUBLE
 DIM DBLTan AS DOUBLE
 DIM DBLTanh AS DOUBLE
 
 QrtrPi = ATAN(1.0)
 DBLTan = TAN(QrtrPi)
 DBLTanh = TANH(DBLTan)
 PRINT DBLTan
 PRINT DBLTanh

Result:


 1
 0.761594155955765

Inverse Hyperbolic Trigonometric functions

Inverse hyperbolic trigonometric functions are used to obtain a radian angle from a hyperbolic trigonometric ratio.

ASINH function

Purpose: ASINH returns the DOUBLE radian value angle of a hyperbolic sine trigonometric ratio.


Syntax:

 RadianAngle = ASINH(HypeSineOfAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Parameters:

  • Data type: DOUBLE
    HypeSineOfAngle The hyperbolic sine of an angle.

Example:


 DIM QrtrPi AS DOUBLE
 DIM DBLSinh AS DOUBLE
 DIM DBLASinh AS DOUBLE
 
 QrtrPi = ATAN(1.0)
 DBLSinh = SINH(QrtrPi)
 DBLASinh = ASINH(DBLSinh)
 PRINT DBLSinh
 PRINT DBLASinh

Result:


 0.86867096148601
 0.785398163397448

ACOSH function

Purpose: ACOSH returns the DOUBLE radian value angle of a hyperbolic cosine trigonometric ratio.


Syntax:

 RadianAngle = ACOSH(HypeCosineOfAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Parameters:

  • Data type: DOUBLE
    HypeCosineOfAngle The hyperbolic cosine of an angle.

Example:


 DIM QrtrPi AS DOUBLE
 DIM DBLCosh AS DOUBLE
 DIM DBLACosh AS DOUBLE
 
 QrtrPi = ATAN(1.0)
 DBLCosh = COSH(QrtrPi)
 DBLACosh = ACOSH(DBLCosh)
 PRINT DBLCosh
 PRINT DBLACosh

Result:


 1.32460908925201
 0.785398163397448

ATANH function

Purpose: ATANH returns the DOUBLE radian value angle of a hyperbolic tangent trigonometric ratio.


Syntax:

 RadianAngle = ATANH(HypeTangentOfAngle AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    RadianAngle A radian angle.

Parameters:

  • Data type: DOUBLE
    HypeTangentOfAngle The hyperbolic tangent of an angle.

Example:


 DIM QrtrPi AS DOUBLE
 DIM DBLTanh AS DOUBLE
 DIM DBLATanh AS DOUBLE
 
 QrtrPi = ATAN(1.0)
 DBLTanh = TANH(QrtrPi)
 DBLATanh = ATANH(DBLTanh)
 PRINT DBLTanh
 PRINT DBLATanh

Result:


 0.655794202632672
 0.785398163397448

LOG function

Purpose: LOG returns the natural logarithmic DOUBLE value of a number.


Syntax:

 NatLogNum = LOG(TheNumber AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    NatLogNum The natural logarithmic value of TheNumber.

Parameters:

  • Data type: DOUBLE
    TheNumber A number.

LOGL function

Purpose: LOGL returns the natural logarithmic LDOUBLE value of a number.


Syntax:

 NatLogNum = LOGL(TheNumber AS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    NatLogNum The natural logarithmic value of TheNumber.

Parameters:

  • Data type: LDOUBLE
    TheNumber A number.

Example 1:


 DIM RetDBL#
 DIM RetLDBL AS LDOUBLE
  
 RetDBL# = LOG(9000.0)
 PRINT RetDBL#
  
 RetLDBL = LOGL(9000.0)
 PRINT RetLDBL

Result:


 9.10497985631836
 9.104979856318356435

Example 2: The following routine uses LOG to calculate the length of a number.


 DIM Number#
 DIM LengthOfNumber#
 
 Number# = 1234567890
 LengthOfNumber# = INT(LOG(Number#) / LOG(10)) + 1
 PRINT LengthOfNumber#

Result:


 10

EXP natural exponential function

Purpose: EXP raises Euler's number, 2.718281828459, to a specified exponent. EXP is the inverse of the natural logarithmic LOG function.


Syntax:

 DBLNatExp = EXP(ExpNumber AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    DBLNatExp Euler's number, 2.718281828459, raised to the power of the exponent ExpNumber.

Parameters:

  • Data type: DOUBLE
    ExpNumber A number.

Example:


 DIM DBLExponent AS DOUBLE
 DIM DBLNatExp AS DOUBLE
 
 DBLExponent = 2.30258509299405
 DBLNatExp = EXP(DBLExponent)
 PRINT DBLNatExp

Result:


 10

LOG10 function

Purpose: LOG10 returns the DOUBLE common, base-10, logarithm of a number.


Syntax:

 ComLogNum = LOG10(TheNumber AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    ComLogNum The common logarithmic value of TheNumber.

Parameters:

  • Data type: DOUBLE
    TheNumber A number.

Example:


 DIM Number#
 DIM LengthOfNumber#
 
 Number# = 1234567890
 LengthOfNumber# = INT(LOG10(Number#) / LOG10(10)) + 1
 PRINT LengthOfNumber#

Result:


 10

LOG10L function

Purpose: LOG10L returns the LDOUBLE common, base-10, logarithm of a number.


Syntax:

 ComLogLDBL = LOG10L(LDBLNumber AS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    ComLogLDBL The common, base-10, logarithmic value of LDBLNumber.

Parameters:

  • Data type: LDOUBLE
    LDBLNumber A number.

Example:


 DIM RetDBL#
 DIM RetLDBL AS LDOUBLE
 
 RetDBL# = LOG10(9000.0)
 PRINT RetDBL#
 
 RetLDBL = LOG10L(9000.0)
 PRINT RetLDBL

Result:


 3.95424250943932
 3.954242509439324875

SQR and SQRT function

Purpose: SQR and SQRT return the square root DOUBLE value of a DOUBLE number.


Syntax 1:

 RetDBL = SQR(DBLNumber AS DOUBLE)

Syntax 2:

 RetDBL = SQRT(DBLNumber AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    RetDBL The square root of DBLNumber.

Parameters:

  • Data type: DOUBLE
    DBLNumber A number.

SQRL and SQRTL function

Purpose: SQRL and SQRTL return the square root LDOUBLE value of an LDOUBLE number.


Syntax 1:

 RetLDBL = SQRL(LDBLNumber AS DOUBLE)

Syntax 2:

 RetLDBL = SQRTL(LDBLNumber AS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    RetLDBL The square root of LDBLNumber.

Parameters:

  • Data type: LDOUBLE
    LDBLNumber A number.

Example:


 DIM RetDBL#
 DIM RetLDBL AS LDOUBLE
 
 RetDBL# = SQRT(3.14159265358979)
 PRINT RetDBL#
 
 RetLDBL = SQRTL(3.141592653589793239L)
 PRINT RetLDBL

Result:


 1.77245385090552
 1.772453850905516027

HYPOT function

Purpose: HYPOT returns, as a DOUBLE value, the length of the hypotenuse of a right angled triangle given the lengths, as DOUBLE numbers, of the adjacent sides.


Syntax:

 DBLHypot = HYPOT(DBLSideA AS DOUBLE, DBLSideB AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    DBLHypot The length of the hypotenuse of a right angled triangle.

Parameters:

  • Data type: DOUBLE
    DBLSideA The length of one of the sides, adjacent to the hypotenuse, of a right angled triangle.
  • Data type: DOUBLE
    DBLSideB The length of the other of the sides, adjacent to the hypotenuse, of a right angled triangle.

HYPOTL function

Purpose: HYPOTL returns, as an LDOUBLE value, the length of the hypotenuse of a right angled triangle given the lengths, as LDOUBLE numbers, of the adjacent sides.


Syntax:

 LDBLHypot = HYPOTL(LDBLSideA AS LDOUBLE, LDBLSideB AS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    LDBLHypot The length of the hypotenuse of a right angled triangle.

Parameters:

  • Data type: LDOUBLE
    LDBLSideA The length of one of the sides, adjacent to the hypotenuse, of a right angled triangle.
  • Data type: LDOUBLE
    LDBLSideB The length of the other of the sides, adjacent to the hypotenuse, of a right angled triangle.

Example:


 DIM DBLSideA#
 DIM DBLSideB#
 DIM DBLHypot#
 DBLSideA# = 3.1
 DBLSideB# = 4.1
 DBLHypot# = HYPOT(DBLSideA#, DBLSideB#)
 PRINT DBLHypot#
 
 
 DIM LDBLSideA AS LDOUBLE
 DIM LDBLSideB AS LDOUBLE
 DIM LDBLHypot AS LDOUBLE
 LDBLSideA = 3.1
 LDBLSideB = 4.1
 LDBLHypot = HYPOTL(LDBLSideA, LDBLSideB)
 PRINT LDBLHypot

Result:


 5.14003891035856
 5.140038910358558525

POW function

Purpose: POW returns, as a DOUBLE, the result of a DOUBLE value base raised to the power of a DOUBLE value exponent.


Syntax:

 DBLPowered = POW(DBLBase AS DOUBLE, DBLExponent AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    DBLPowered The value of DBLBase raised to DBLExponent.

Parameters:

  • Data type: DOUBLE
    DBLBase The base.
  • Data type: DOUBLE
    DBLExponent The exponent.

Example:


 DIM DBLPowered AS DOUBLE
 DIM DBLBase AS DOUBLE
 DIM DBLExponent AS DOUBLE
  
 DBLBase = 2
  
 FOR INTEGER i = 2 TO 16
  DBLExponent#  = i
  DBLPowered# = POW(DBLBase#, DBLExponent#)
  PRINT DBLPowered#
 NEXT i

Result:


 4
 8
 16
 32
 64
 128
 256
 512
 1024
 2048
 4096
 8192
 16384
 32768
 65536

POWL function

Purpose: POWL returns, as an LDOUBLE value, the result of an LDOUBLE value base raised to the power of an LDOUBLE value exponent.


Syntax:

 LDBLPowered = POWL(LDBLBase AS LDOUBLE, LDBLExponent AS LDOUBLE)

Return Value:

  • Data type: LDOUBLE
    LDBLPowered The value of LDBLBase raised to LDBLExponent.

Parameters:

  • Data type: LDOUBLE
    LDBLBase The base.
  • Data type: LDOUBLE
    LDBLExponent The exponent.

Example:


 DIM LDBLPowered AS LDOUBLE
 DIM LDBLBase AS LDOUBLE
 DIM LDBLExponent AS LDOUBLE
   
 LDBLBase = 2.1
   
 FOR INTEGER i = 1.1 TO 16.1 STEP 1
  LDBLExponent  = i
  LDBLPowered = POWL(LDBLBase, LDBLExponent)
  PRINT LDBLPowered
 NEXT i

Result:


 2.100000000000000089
 4.410000000000000373
 9.261000000000001175
 19.44810000000000329
 40.84101000000000864
 85.76612100000002176
 180.1088541000000533
 378.2285936100001279
 794.2800465810003022
 1667.988097820100705
 3502.775005422211629
 7355.827511386644732
 15447.23777391195459
 32439.19932521510601
 68122.3185829517255
 143056.8690241986296

MOD function

Purpose: MOD returns, as a DOUBLE value, the remainder of a division operation.

Unlike most other BASIC implementations of MOD, which return an INTEGER, BCX MOD returns a DOUBLE, including any remaining fraction. For a procedure which returns, as an INTEGER value, the remainder of a division operation, see the below IMOD function.


Syntax 1: As Function

 Remainder = MOD(Dividend AS DOUBLE, Divisor AS DOUBLE)

Return Value:

  • Data type: DOUBLE
    Remainder The remainder of the division operation.

Parameters:

  • Data type: DOUBLE
    Dividend The value to be divided.
  • Data type: DOUBLE
    Divisor The value dividing Dividend.

Example 1:


 DIM Remainder#
 DIM Dividend#
 DIM Divisor#
 
 Dividend# = 5.3
 Divisor#  = 2.0
 
 Remainder# = MOD(Dividend#, Divisor#)
 PRINT Remainder#

Result:


 1.3

Syntax 2: As Operator

 Remainder = Dividend AS DOUBLE MOD Divisor AS DOUBLE

Return Value:

  • Data type: DOUBLE
    Remainder The remainder of the division operation.

Parameters:

  • Data type: DOUBLE
    Dividend The value to be divided.
  • Data type: DOUBLE
    Divisor The value dividing Dividend.

Example 2:


 DIM Remainder#
 DIM Dividend#
 DIM Divisor#
 
 Dividend# = 5.3
 Divisor#  = 2.0
 
 Remainder# = Dividend# MOD Divisor#
 PRINT Remainder#

Result:


 1.3

Remarks:
In QuickBASIC, the MOD remainder operator uses integer division with rounding in calculations. Keep this in mind if you are porting some old QuickBASIC code that uses the MOD remainder operator.

Example:

The QuickBASIC MOD calculation


 19.0 MOD 6.7
  

BCX equivalent result, can be had using the technique shown in this BCX example.


 DIM AS INTEGER RetInt
 
 RetInt = QB_MOD(19.0, 6.7)
 
 PRINT RetInt
 
 FUNCTION QB_MOD(dividend AS DOUBLE, divisor AS DOUBLE) AS INTEGER
   '******************************************************** 
   ' Replicates the QBasic modulus function algorithm 
   '******************************************************** 
   DIM AS INTEGER idividend, idivisor
   idividend = INT(ROUND(dividend, 0))
   idivisor = INT(ROUND(divisor, 0))
   FUNCTION = IMOD(idividend, idivisor)
 END FUNCTION

Result:


 5

IMOD function

Purpose: IMOD returns, as an INTEGER value, the remainder of a division operation.


Syntax:

 Remainder = IMOD(Dividend AS INTEGER, Divisor AS INTEGER)

Return Value:

  • Data type: INTEGER
    Remainder The remainder of the division operation.

Parameters:

  • Data type: INTEGER
    Dividend The value to be divided.
  • Data type: DOUBLE
    Divisor The value dividing Dividend.

Example:


 DIM Remainder%
 DIM Dividend%
 DIM Divisor%
 
 Dividend% = 5
 Divisor%  = 2
 
 Remainder% = IMOD(Dividend%, Divisor%)
 PRINT Remainder%

Result:


 1

Remarks:

% modulus operator

Functionally equivalent to the BCX IMOD function, the C language modulus operator % is accepted by BCX in BASIC expressions.

When using the % modulus operator, a space must be to the left and right of of the % symbol.

Example:


  DIM Remainder AS INTEGER
  DIM Dividend AS INTEGER
  DIM Divisor AS INTEGER
  
  Dividend = 5
  Divisor  = 2
  
  Remainder = Dividend % Divisor
  PRINT Remainder

Result:


 1