Method

# CLong

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Returns the numeric form of a `string</api/data_types/string>` as an `Int64</api/data_types/additional_types/int64>`.

## Usage

``` xojo
result = CLong(str)
```

| Part   | Type                                            | Description                                            |
|--------|-------------------------------------------------|--------------------------------------------------------|
| result | `Int64</api/data_types/additional_types/int64>` | The numeric equivalent of the string passed.           |
| str    | `String</api/data_types/string>`                | Any valid `string</api/data_types/string>` expression. |

## Notes

The <span class="title-ref">CLong</span> function stops reading the `string</api/data_types/string>` at the first character it doesn't recognize as part of a number. All other characters are automatically stripped.

It does recognize prefixes `&o</api/language/literals/o>` (octal), `&b</api/language/literals/b>` (binary), and `&h</api/language/literals/h>` (hexadecimal). However, spaces are not allowed in front of the ampersand. That is, "`&hFF</api/language/literals/h>`" returns 0, but "`&hFF</api/language/literals/h>`" returns 255.

CLong returns zero if *string* contains no numbers.

## Sample code

This code use the <span class="title-ref">CLong</span> function to return the numbers contained in a `string</api/data_types/string>` literal or a `string</api/data_types/string>` variable

``` xojo
Var n As Int64
n = CLong("12345") ' returns 12345
n = CLong(" 12345") ' returns 0
n = CLong("123 45") ' returns 123
n = CLong("&hFFF") ' returns 4095
n = CLong("&b1111") ' returns 15
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div id="clong.see_also">

<div class="seealso">

`String<string.todouble>`, `CStr</api/text/cstr>`, `Int64.FromString<integer.fromstring>`, `Str</api/text/str>`, `Val</api/text/val>` functions; `&b</api/language/literals/b>`, `&h</api/language/literals/h>`, `&o</api/language/literals/o>` literals; `Int64</api/data_types/additional_types/int64>` data type

</div>

</div>
