Skip to content
Paul Squires edited this page Oct 19, 2026 · 2 revisions

Home › Converting Data Types › CDbl

CDbl

Converts a number or string to a Double.

Syntax

Declare Function CDbl ( ByVal expression As datatype ) As Double
Type typename
Declare Operator Cast ( ) As Double
End Type

Parameters

  • expression
  • datatype
  • typename

Description

The CDbl function returns a 64-bit Double value. The function does not check for an overflow, so be sure not to pass a value outside the representable range of the Double data type. The name can be explained as 'Convert to DouBLe'.

If the argument to CDbl is a string expression, it is first converted to numeric by using Val.

Return Value

A Double precision value.

Remarks

Usage

result = CDbl( numeric expression )

result = CDbl( string expression )

result = CDbl( user defined type )

Differences from QB

  • The string argument was not allowed in QB

See also

Examples

' Using the CDBL function to convert a numeric value

'Create an DOUBLE variable

Dim numeric_value As Double

'Convert a numeric value

numeric_value = CDbl(-12345678.123)

'Print the result, should return -12345678.123

Print numeric_value

Sleep

Category: Converting Data Types
Kind: function


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally