# Infinitely summing 0.1 gives error

**URL:** <https://chapel.discourse.group/t/infinitely-summing-0-1-gives-error/3490>\
**Category:** Users\
**Created:** [February 15, 2021, 9:24pm UTC](https://chapel.discourse.group/t/infinitely-summing-0-1-gives-error/3490 "2021-02-15T21:24:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nelsonluisdias](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/nelsonluisdias/32/691_2.png) [@nelsonluisdias](https://chapel.discourse.group/u/nelsonluisdias)\
**Post date:** [February 15, 2021, 9:24pm UTC](https://chapel.discourse.group/t/infinitely-summing-0-1-gives-error/3490/1 "2021-02-15T21:24:27Z")

</div>

Hello! The following little program should run forever (until overflow, maybe)

```chapel
var x = 0.0;
while true do {
   x += 0.1;
   writeln(x);
}

```

but instead it stops after some time with the following last lines of output:  
1.03101e+05  
1.03101e+05  
1.03101e+05  
1.03101e+05  
uncaught SystemError: Invalid argument: internal error (while writing real(64) with path "/dev/pts/0" offset 8257534)  
inf.chpl:4: thrown here  
inf.chpl:4: uncaught here

C and Python versions happily go on forever. I believe this is a bug ...

---

<div class="post-metadata">

**Author:** ![nelsonluisdias](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/nelsonluisdias/32/691_2.png) [@nelsonluisdias](https://chapel.discourse.group/u/nelsonluisdias)\
**Post date:** [February 15, 2021, 10:09pm UTC](https://chapel.discourse.group/t/infinitely-summing-0-1-gives-error/3490/2 "2021-02-15T22:09:34Z")

</div>

this one, however, works fine (or at least for a much longer time):

```chapel
var x = 0.0;
while true do {
   x += 0.1;
   writef("%30r\n",x);
}

```

---

<div class="post-metadata">

**Author:** ![mppf](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@mppf](https://chapel.discourse.group/u/mppf)\
**Post date:** [February 16, 2021, 2:41pm UTC](https://chapel.discourse.group/t/infinitely-summing-0-1-gives-error/3490/3 "2021-02-16T14:41:43Z")

</div>

Hi nelsonluisdias -

Thanks very much for letting us know about this bug. We usually track bug reports as GitHub issues and so I went ahead and created [Infinitely summing 0.1 gives error · Issue #17170 · chapel-lang/chapel · GitHub](https://github.com/chapel-lang/chapel/issues/17170) for it.

I have prepared a fix for this bug in this PR [fix I/O bug in \_ftoa\_core to solve issue 17170 by mppf · Pull Request #17171 · chapel-lang/chapel · GitHub](https://github.com/chapel-lang/chapel/pull/17171) which I expect to merge once testing is complete. It should be available in the upcoming 1.24 release.

---

<div class="post-metadata">

**Author:** ![nelsonluisdias](https://yyz2.discourse-cdn.com/free1/user_avatar/chapel.discourse.group/nelsonluisdias/32/691_2.png) [@nelsonluisdias](https://chapel.discourse.group/u/nelsonluisdias)\
**Post date:** [February 16, 2021, 5:28pm UTC](https://chapel.discourse.group/t/infinitely-summing-0-1-gives-error/3490/4 "2021-02-16T17:28:35Z")

</div>

Hi Michael,

Great to know! Looking forward to 1.24

Cheers  
Nelson
