KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Function return notation.

  • Function return notation.

    Posted by ptech127 on March 17, 2022 at 12:00 am

    Why does addition return 0w?

    Why does multiplication return 0n?

    ptech127 replied 9 months, 1 week ago 2 Members · 1 Reply
  • 1 Reply
  • Laura

    Administrator
    March 18, 2022 at 12:00 am

    Two expressions: one multiplies 0+0 by 1%0&0; the other adds them.

    The sum of two long zeros is long zero.

    1%0 is float infinity 0w. The type of the right argument does not matter; Divide always returns a float.

    So the comparison is between 0*0w and 0+0w.

    The latter is 0w. Surely expected: infinity plus x is infinity.

    The unexpected result then is 0*0w. Is not 0*x always zero? But here its a float null 0n. I do not know the mathematical justification for this; perhaps someone else can shed light?

    BTW your lambdas could be simpler:

    test1:{(x+y)*1%x&y} 
    test2:{(x+y)+1%x&y}

     

     

     

     

Log in to reply.