# How to convert double to int?

**URL:** <https://forum.robusta.ai/t/how-to-convert-double-to-int/619>\
**Category:** JavaScript\
**Tags:** excel, javascript, dataset\
**Created:** [October 27, 2023, 6:08am UTC](https://forum.robusta.ai/t/how-to-convert-double-to-int/619 "2023-10-27T06:08:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![karagozenes](https://avatars.discourse-cdn.com/v4/letter/k/41988e/32.png) [@karagozenes](https://forum.robusta.ai/u/karagozenes)\
**Post date:** [October 27, 2023, 6:08am UTC](https://forum.robusta.ai/t/how-to-convert-double-to-int/619/1 "2023-10-27T06:08:20Z")

</div>

Hello,

i want to get a random number between 0 and 149. i used Math.random() function. i tried to convert to int which i get from this function but i couldnt get it as integer, i get it as double. i am going to use this variable in dataset-get action row property. Can you help me? Thanks.

This is the script:

```auto
var randomSayi = execution.getVariable("randomSayi");
randomSayi = Math.floor(Math.random() * 149);
randomSayi = parseInt(randomSayi);
execution.setVariable("randomSayi", randomSayi);

```

where i want to use:  
 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robusta1/original/1X/3c9d801684ebb401390c204a7e7262517542de5c.png)

error:

> Cannot deserialize value of type `java.lang.Integer` from String "12.0": not a valid Integer value; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.lang.Integer` from String "12.0": not a valid Integer value\n at [Source: (PushbackInputStream); line: 1, column: 29] (through reference chain: com.daphne.services.resultset.dto.ResultSetDTO["row"])“,“path”:”/resultset/get"}

---

<div class="post-metadata">

**Author:** ![Yasin.Baykan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robusta.ai/yasin.baykan/32/86_2.png) [@Yasin.Baykan](https://forum.robusta.ai/u/Yasin.Baykan)\
**Post date:** [October 27, 2023, 7:32am UTC](https://forum.robusta.ai/t/how-to-convert-double-to-int/619/2 "2023-10-27T07:32:06Z")

</div>

Hello ,  
Please use this script

randomSayi = Number(randomSayi).intValue();

---

<div class="post-metadata">

**Author:** ![karagozenes](https://avatars.discourse-cdn.com/v4/letter/k/41988e/32.png) [@karagozenes](https://forum.robusta.ai/u/karagozenes)\
**Post date:** [October 27, 2023, 8:00am UTC](https://forum.robusta.ai/t/how-to-convert-double-to-int/619/3 "2023-10-27T08:00:01Z")

</div>

it worked, thank you.
