-0f

Hello All!

I am new to this forum and this is my first question here.

I have been using kdb to develop solutions for my company for about 8 months now.

I have a rather simple question:

q)a:-3i

q)b:0f

q)a*b
-0f

I dont want to see the -0. 

Note that b can be non zero (for example 3), so simply taking the absolute value would not serve my purpose (taking abs would give output as 9, but i want to see -9).

Any help is much appreciated! Thanks a lot.

Giridhar

CONFIDENTIALITY NOTICE: This e-mail and any attachments are for the exclusive
and confidential use of the recipient(s) who we intend for institutional
customers as opposed to retail customers and may constitute non-public information.
If you received this e-mail in error, disclosing, copying, distributing or taking
any action in reliance of this e-mail is strictly prohibited and may be unlawful.
Instead, please notify us immediately by return e-mail and promptly delete this
message and its attachments from your computer system as we do not waive any work
product or other applicable legal privilege(s) by the transmission of this message.
NOTE: The information in this e-mail does not constitute tradingadvice.

This might work for you

q){signumabs x}ab

0f

Terry

Thanks a lot @TerryLynch

I found another solution by chance:

q)0f+a*b

0f

Just adding 0f seems to work. I don’t have an explanation for this behaviour, but for cleanliness of code I am going with this…

Do you know why this works?

Oh nice! Yeah that is cleaner. I don’t know why it works per se, other than that its clear that kdb resolves 0f plus -0f to be 0f. Possibly some edge case logic.

https://en.wikipedia.org/wiki/Signed_zero#Arithmetic

This is very helpful. Thanks a lot @Charles Skelton