# Weird values from an int function

**URL:** <https://forum.arduino.cc/t/weird-values-from-an-int-function/520476>\
**Category:** Programming\
**Created:** [April 15, 2018, 4:57pm UTC](https://forum.arduino.cc/t/weird-values-from-an-int-function/520476 "2018-04-15T16:57:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EmPuls](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@EmPuls](https://forum.arduino.cc/u/EmPuls)\
**Post date:** [April 15, 2018, 4:57pm UTC](https://forum.arduino.cc/t/weird-values-from-an-int-function/520476/1 "2018-04-15T16:57:18Z")

</div>

Hey Guys,

I'm stuck with an error that I don't understand in any way:

This is not exactly my code but it does the same:

```cpp
Serial.print(funktion1(voltage));

int funktion1(float value){
    if (value < 1,5){
        return 1;
    }
    else{
    return 0;
}
}

```

I would expect this to give me either 0 or 1 but it gives me values like: -1793 or 2355.  
This part of the code worked fine until I started to add EEPROM operations. Does anybody has an idear on this?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![ieee488](https://avatars.discourse-cdn.com/v4/letter/i/d2c977/32.png) [@ieee488](https://forum.arduino.cc/u/ieee488)\
**Post date:** [April 15, 2018, 5:02pm UTC](https://forum.arduino.cc/t/weird-values-from-an-int-function/520476/2 "2018-04-15T17:02:12Z")

</div>

Something else is going on with the code you did not post.

It works fine for me.

---

<div class="post-metadata">

**Author:** ![EmPuls](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@EmPuls](https://forum.arduino.cc/u/EmPuls)\
**Post date:** [April 15, 2018, 5:03pm UTC](https://forum.arduino.cc/t/weird-values-from-an-int-function/520476/3 "2018-04-15T17:03:51Z")

</div>

Just found my mistake: In function1 I checked for else if instead of else and that if was not the case anymore so it did not return anything, therefore I had these weird Numbers.

---

<div class="post-metadata">

**Author:** ![BulldogLowell](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@BulldogLowell](https://forum.arduino.cc/u/BulldogLowell)\
**Post date:** [April 15, 2018, 5:04pm UTC](https://forum.arduino.cc/t/weird-values-from-an-int-function/520476/4 "2018-04-15T17:04:00Z")

</div>

> ieee488:  
> It works fine for me.

```arduino
if (value < 1,5){

```

how are decimal values represented in C++?  
what is the comma operator?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 11:08pm UTC](https://forum.arduino.cc/t/weird-values-from-an-int-function/520476/5 "2021-05-05T23:08:03Z")

</div>

Closed on May 5, 2021, 11:08pm UTC


