# .Q.f output unexpected value in kdb4.0

**URL:** <https://forum.kx.com/t/q-f-output-unexpected-value-in-kdb4-0/13013>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [September 20, 2023, 4:19am UTC](https://forum.kx.com/t/q-f-output-unexpected-value-in-kdb4-0/13013 "2023-09-20T04:19:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BaiChen1](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@BaiChen1](https://forum.kx.com/u/BaiChen1)\
**Post date:** [September 20, 2023, 4:19am UTC](https://forum.kx.com/t/q-f-output-unexpected-value-in-kdb4-0/13013/1 "2023-09-20T04:19:00Z")

</div>

&nbsp;

Hello all,

Came across a problem with .Q.f .&nbsp;

We expected the first output to be 4194304.98 .&nbsp;&nbsp;

I saw this issue only in kdb4.0.&nbsp;

Output in kdb3.5 is expected.&nbsp;

Any advice is appreciated.&nbsp;

---

<div class="post-metadata">

**Author:** ![rocuinneagain1](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rocuinneagain1](https://forum.kx.com/u/rocuinneagain1)\
**Post date:** [September 20, 2023, 10:20am UTC](https://forum.kx.com/t/q-f-output-unexpected-value-in-kdb4-0/13013/2 "2023-09-20T10:20:00Z")

</div>

From 3.6 Readme

```
2018.09.26 NEW added -27! as a more precise, builtin version of .Q.f. n.b. It is atomic and doesn't take \P into account. e.g. q)("123456789.457";"123456790.457")~-27!(3i;0 1+2#123456789.4567)

```

The definition of&nbsp;`.Q.f`&nbsp;changed at this time also - when comparing&nbsp;`q.k`&nbsp;file definitions:

`3.6.0 2018.09.10`

```
f:{$[^y;"";y<0;"-",f[x;-y];y<1;1_f[x;10+y];9e15>j:"j"$y*/x#10;(x_j),".",(x:-x)#j:$j;$y]}

```

`3.6.0 2018.10.03`

```
f:{$[^y;"";y<0;"-",f[x;-y];y<1;1_f[x;10+y];9e15>j:"j"$y*prd x#10f;(x_j),".",(x:-x)#j:$j;$y]}

```

&nbsp;

&nbsp;Floating point numbers are not exact and such behaviours should be expected in certain cases:

https://code.kx.com/q/basics/precision/

&nbsp;

They are approximations:

```
q)\P 0 q)4194303.975 4194303.9750000001 q)4194304.975 4194304.9749999996

```

&nbsp;

The same in C:

```
int main() { double x = 4194303.975; printf("%10.10f\n",x); }

```

Result:

```
4194303.9750000001

```

&nbsp;

If you find that you need exact decimal rounding, consider whether you actually need to operate in fixed-point, rather than floating-point.  
e.g. keep monetary values in integral millicents etc.

&nbsp;

&nbsp;

&nbsp;
