Page 1 of 1

### [v2] String to number

Posted: 12 Aug 2018, 07:55
I need to convert the values ​​in the string to numeric values. I found this very difficult. Do you have any quick methods?

I found that converting them requires a complicated process:
e.g. ["6.9","232","-8.3"]

### Re: String to number

Posted: 12 Aug 2018, 08:10
You can just calculate with them?
In AHK every string can be used like a number as long as it only consists of a single number (e.g. the numbers you presented.)

### Re: String to number  Topic is solved

Posted: 12 Aug 2018, 08:17
There are two (suitable) functions available, integer and float.

### Re: String to number

Posted: 12 Aug 2018, 08:24
Yes, but as some DLL parameters, need to convert.

### Re: String to number

Posted: 12 Aug 2018, 08:27
Helgef wrote:There are two (suitable) functions available, integer and float.
Can you link the addresses of these two functions? I can't find.

### Re: String to number

Posted: 12 Aug 2018, 08:30
arcticir wrote:
Helgef wrote:There are two (suitable) functions available, integer and float.
Can you link the addresses of these two functions? I can't find.
https://lexikos.github.io/v2/docs/commands/Integer.htm
https://lexikos.github.io/v2/docs/commands/Float.htm
https://lexikos.github.io/v2/docs/commands/String.htm
https://lexikos.github.io/v2/docs/commands/Type.htm

### Re: String to number

Posted: 12 Aug 2018, 08:52
thank you very much. My "help document" is too old.

### Re: String to number

Posted: 12 Aug 2018, 09:02
One problem is that its conversion is not accurate, it is very bad when converting JSON data:

Float("6.9") ;==>6.9000000000000004

### Re: String to number

Posted: 12 Aug 2018, 09:07
You might be interested in this topic.

### Re: String to number

Posted: 12 Aug 2018, 09:38
this topic, in addition to explaining why "Float()" cannot be accurately converted, is there any help for "accurate conversion type"?

### Re: String to number

Posted: 12 Aug 2018, 10:26
AutoHotkeys floating point numbers are as precise as a double sized float (its the standar size).
If you want more precision you need a different type.

### Re: String to number

Posted: 12 Aug 2018, 22:54
The conversion is accurate. The data type is not (for decimal fractions). You can't even choose to use or simulate a different data type if you're using DllCall. At some point the value must be converted to the type that the external function requires.