---
title: "strfloat()"
canonical: "https://docs.xirgoglobal.com/space/SD/27134786/strfloat()"
format: markdown
---
### <span style="color: #36b37e">Description</span><span style="color: #36b37e">** **</span>

Convert from text (string) to ﬂoating point.

### <span style="color: #36b37e">Syntax</span>

`strfloat(string[]);`

### <span style="color: #36b37e">Parameters</span>

| **Variable** | **Input** |
| --- | --- |
| `string ` | A string containing a ﬂoating point number in characters. This may be either a packed or unpacked string.<br>The string may specify a fractional part, for example “123.45”. |

### <span style="color: #36b37e">Returns</span>

The value in the string, or zero if the string did not start with a valid number.

### <span style="color: #36b37e">Function call example</span>

##### **Example of converting string to float**

```java
new data1[7] = ''125.89'';
new Float: strToFl;
   
main(){
 strToFl = strfloat(data1);
  while(1){
    Delay(100);                                     
  }
}
```

### <span style="color: #36b37e">Notes and Warnings</span>

Use unpacked string by writing two times single comma (''example'') instead of writing single double comma ("example").

When using unpacked string always leave one more array element:

<sup>new data1[7] = ''125.89'';</sup>

Here we see that to store whole string we'd need only 6 array elements (since 125.89 is 6 elements), but we have to add one extra array element to store final zero, that's why data1 array size is 7 instead of 6.