# Why relay.floor\_mod allows float64?

**URL:** <https://discuss.tvm.apache.org/t/why-relay-floor-mod-allows-float64/12073>\
**Category:** Questions\
**Created:** [February 12, 2022, 3:03pm UTC](https://discuss.tvm.apache.org/t/why-relay-floor-mod-allows-float64/12073 "2022-02-12T15:03:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![wrongtest](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/wrongtest/32/2008_2.png) [@wrongtest](https://discuss.tvm.apache.org/u/wrongtest)\
**Post date:** [February 13, 2022, 9:17am UTC](https://discuss.tvm.apache.org/t/why-relay-floor-mod-allows-float64/12073/2 "2022-02-13T09:17:04Z")

</div>

Hi, as a context, we can see other dl-frameworks also allow that like [tf.math.floormod &nbsp;|&nbsp; TensorFlow Core v2.8.0](https://www.tensorflow.org/api_docs/python/tf/math/floormod).

For TVM, below is where float `floormod` is lowered to normal arithmetics as `a - floor(a/b) * b`

> <https://github.com/apache/tvm/blob/7396be5645fa59cb10ae8ee14b718dbf7737390b/src/tir/transforms/lower_intrin.cc#L184-L186>

Since the case in the test script is to compute floor\_mod(e^c1, c2) . I think it would be great to check what sub-step actually cause the difference (`exp`, `div`, or `floor()`?). It is known that CUDA arithmetics do not take exact same precision with c/c++ standard math libs, [Programming Guide :: CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#mathematical-functions-appendix).

In my environment, the cpu result match what I test with raw python:

```auto
>>> import math
>>> def f(a,b): return a - math.floor(a/b) * b
...
>>> f(math.exp(415.748715), 787.644532)
4.606887725612233e+164

```

---

_[View the full topic](https://discuss.tvm.apache.org/t/why-relay-floor-mod-allows-float64/12073)._
