If you always want 4 digits<o:p></o:p>
string`long$x*100<o:p></o:p>
<o:p> </o:p>
If you want 4 digits or more<o:p></o:p>
string[x*100]except"."<o:p></o:p>
<o:p> </o:p>
But if you have too many digits you have to be quite careful with the \P setting. E.g.:<o:p></o:p>
q){string`long$x*100}46.3<o:p></o:p>
“4630”<o:p></o:p>
q){string[x*100]except"."}46.3<o:p></o:p>
“4630”<o:p></o:p>
q){string[x*100]except"."}46.31231938 /truncates the string<o:p></o:p>
“4631232”<o:p></o:p>
q)\P 10<o:p></o:p>
q){string[x*100]except"."}46.31231938 /ok for this number<o:p></o:p>
“4631231938”<o:p></o:p>
q)\P 0<o:p></o:p>
q){string[x*100]except"."}46.31231938 /prints the floating point artifact<o:p></o:p>
“46312319379999999”<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
From: personal-kdbplus@googlegroups.com [mailto:personal-kdbplus@googlegroups.com] On Behalf Of rtrader
Sent: Wednesday, June 29, 2016 6:04 AM
To: Kdb+ Personal Developers <personal-kdbplus@googlegroups.com>
Subject: Re: [personal kdb+] removing decimal point from a number/ converting float to long<o:p></o:p>
<o:p> </o:p>
Thanks that works, I know it should be 4 digits because they are prices do you know anyway to force the number of digits?
On Monday, June 27, 2016 at 12:41:24 PM UTC-5, David D wrote:<o:p></o:p>
You can go stringexcept “.”<o:p></o:p>
<o:p></o:p>
How do you know you want 46.3 to turn into 4630 not 463?<o:p></o:p>
<o:p></o:p>
From: personal…@googlegroups.com [mailto:personal…@googlegroups.com] On Behalf Of rtrader
Sent: Monday, June 27, 2016 9:19 AM
To: Kdb+ Personal Developers <personal…@googlegroups.com>
Subject: [personal kdb+] removing decimal point from a number/ converting float to long<o:p></o:p>
<o:p></o:p>
Basically what I would like to do is strip the decimal point from a number eg turn 46.30 to 4630, or would I just multiply by 10 in this example and then truncate. The problem with that is I may have more digits in other numbers like 1.7296875<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
Thanks<o:p></o:p>
–
Submitted via Google Groups