# Multiply with floating numbers

**URL:** <https://forum.ansible.com/t/multiply-with-floating-numbers/20237>\
**Category:** Ansible Project\
**Created:** [January 16, 2016, 1:30pm UTC](https://forum.ansible.com/t/multiply-with-floating-numbers/20237 "2016-01-16T13:30:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dewangga\_Bachrul\_Ala](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@Dewangga\_Bachrul\_Ala](https://forum.ansible.com/u/Dewangga_Bachrul_Ala)\
**Post date:** [January 16, 2016, 1:30pm UTC](https://forum.ansible.com/t/multiply-with-floating-numbers/20237/1 "2016-01-16T13:30:06Z")

</div>

I’ve search some reference but still got no luck about divide operations in ansible.

# default/main.yml

mariadb\_setmem: “{{ ansible\_memtotal\_mb _1024_1024 }}”  
mariadb\_misc\_query\_prealloc\_size: “{{ mariadb\_setmem \*0.01 }}”

# task/main.yml

- name: Debugging Value  
debug:  
msg: “{{ mariadb\_misc\_query\_prealloc\_size }}”

And got error.  
fatal: [vagrant01] =\> Failed to template {{ mariadb\_misc\_query\_prealloc\_size }}: Failed to template {{ mariadb\_setmem \*0.01 }}: an unexpected type error occurred. Error was can’t multiply sequence by non-int of type ‘float’

Is there any hints to got the results of the math operations and round it?  
Any helps are appreciated.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 16, 2016, 11:11pm UTC](https://forum.ansible.com/t/multiply-with-floating-numbers/20237/2 "2016-01-16T23:11:54Z")

</div>

That error indicates that you are trying to multiply a sequence, in this case I am assuming a string and a float.

mariadb\_setmem is cast to a string. You might try:

{{ mariadb\_setmem|float \* 0.01 }}

Also that functionality is provided by jinja2. Math operations are described at [http://jinja.pocoo.org/docs/dev/templates/#math](http://jinja.pocoo.org/docs/dev/templates/#math)

---

<div class="post-metadata">

**Author:** ![Dewangga\_Bachrul\_Ala](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@Dewangga\_Bachrul\_Ala](https://forum.ansible.com/u/Dewangga_Bachrul_Ala)\
**Post date:** [January 18, 2016, 1:09am UTC](https://forum.ansible.com/t/multiply-with-floating-numbers/20237/3 "2016-01-18T01:09:48Z")

</div>

Hello Matt,

Thank you, it’s working 🙂

Pada Minggu, 17 Januari 2016 06.12.04 UTC+7, Matt Martz menulis:
