Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kdb - string to double or float

Tags:

kdb

q-lang

I am trying to convert a string into a double or a float in KDB - the string contains a number with "accounting" format of the like of 2,228,25 (amount) - is I use something like "j"$amount I get 50 44 50 50 56 46 50 53 as a return value. How do I convert that string into a proper number? Thanks

like image 634
GiPoldo Avatar asked Jan 04 '23 22:01

GiPoldo


1 Answers

When casting strings to atoms of other types in kdb+, you must use capital letters to cast. Casting a string with commas to a number will return null values, so try removing them using either except or ssr.

"J"$"2,228,25" except ","

or

"J"$ssr["2,228,25";",";""]
like image 99
Conor Cadogan Avatar answered Feb 15 '23 20:02

Conor Cadogan