# Bytes value wraps to negative value

**URL:** <https://discuss.elastic.co/t/bytes-value-wraps-to-negative-value/338533>\
**Category:** Elasticsearch\
**Created:** [July 17, 2023, 10:18am UTC](https://discuss.elastic.co/t/bytes-value-wraps-to-negative-value/338533 "2023-07-17T10:18:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddie4](https://avatars.discourse-cdn.com/v4/letter/e/838e76/32.png) [@eddie4](https://discuss.elastic.co/u/eddie4)\
**Post date:** [July 17, 2023, 10:18am UTC](https://discuss.elastic.co/t/bytes-value-wraps-to-negative-value/338533/1 "2023-07-17T10:18:48Z")

</div>

Hello,

Am attempting to multiply the number of bytes from netflow by 100. This is to offset the sampling rate.

The pipeline has the following script:

```auto
  {
    "script": {
      "source": "ctx.network.true_bytes2 = ctx.source.bytes * 100;"
    }
  },

```

Both fields are long's so A signed 64-bit integer. Which should allow me more then enough room to store this data usage. However I can see that the true\_bytes seems to be wraping ( overflowing and starting at minus value).

 ![data view_network.bytes](https://us1.discourse-cdn.com/elastic/original/3X/f/6/f623809f7497792cdea98fce6c127074bcee5070.png)  
 ![data view_source.bytes](https://us1.discourse-cdn.com/elastic/original/3X/8/1/81be647c3a9743707a0dfaa8232c890a0c9cf811.png)

The results are fine under the 20MB. I am truly at a loss what could be the cause of this issue.

 ![weird behavior2](https://us1.discourse-cdn.com/elastic/original/3X/1/c/1c2ae3ad338632a8d37d2dee4a1dff5f10411abe.png)

---

<div class="post-metadata">

**Author:** ![eddie4](https://avatars.discourse-cdn.com/v4/letter/e/838e76/32.png) [@eddie4](https://discuss.elastic.co/u/eddie4)\
**Post date:** [July 17, 2023, 1:48pm UTC](https://discuss.elastic.co/t/bytes-value-wraps-to-negative-value/338533/2 "2023-07-17T13:48:14Z")

</div>

Issue seems to be solved when defining the variable as a long.

Why you need to cast a long to a long when it already is a long dunno. But it solved the issue.

```
"script": {
  "source": "long bytes = ctx.source.bytes;\r\nctx.network.true_bytes = bytes * 100;"
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 14, 2023, 1:48pm UTC](https://discuss.elastic.co/t/bytes-value-wraps-to-negative-value/338533/3 "2023-08-14T13:48:39Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
