### Ruby related euler constant question

Posted:

**Fri Aug 23, 2019 2:28 pm**
by **wlangfor@uoguelph.ca**

### Re: Ruby related euler constant question

Posted:

**Fri Aug 23, 2019 6:55 pm**
by **trogluddite**

TBH, I have to agree with what Quora says - it's not at all clear what you're asking. You seem to want to know how to translate some algebra into code; but then, rather than providing an example of an algebraic formula that you're trying to translate, you provide some (broken?) code with no indication of what you expect it to do nor what you intend to use it for.

If you want a specific formula translating for a specific application, then you need to say what those are, and then we can try to help you. OTOH, if you want to know in general how Euler's constant is used, no answer is possible without using algebra - and when it's used in DSP equations, that usually means having to understand the maths of imaginary/complex numbers (it's a bit of a circular problem*, I realise, but unfortunately there's no avoiding that.)

(* Maths geek pun unintentional!)

### Re: Ruby related euler constant question

Posted:

**Fri Aug 23, 2019 7:31 pm**
by **wlangfor@uoguelph.ca**

Well, it only converts the numbers into a float using euler's. My real question is why it deviates.

Please check My limiter called esquire for a working example. It would seem that would be the best way of explaining:

http://dsprobotics.com/support/viewtopic.php?f=3&t=16533&p=52541&hilit=esquire#p52541I was in a rush when posting, sorry. But You'll see what I am saying. I'll make some images etc so as to make it clearer if that is required.

### Re: Ruby related euler constant question

Posted:

**Fri Aug 23, 2019 8:12 pm**
by **trogluddite**

Aah, yes I see now - not so bad then. It's just that the Quora code example looked very similar to one of the very common Euler equations which is much more complex* to explain mathematically.

If you're seeing a difference in value between Ruby and, say, the same calculation done with 'green' floats, it's probably just because of number precision. Ruby Float numbers are always 64-bit ("double-precision"), even in 32-bit versions of FlowStone, and Ruby might also use a different version of the function for raising to a power. Because of that, there will be slight differences in the result depending which method you use to do the calculation, because they will round-off the values differently. This can be a problem sometimes for very small numbers, because a small 64-bit number might get rounded down to zero (or a denormal number) when truncated to 32-bits - and zero is often a bit of a problem number for mathematical equations!

If you need to use Euler's constant in 'green' maths, you can just put its value into a 'float' box, but 32-bit green will always round it to roughly 6 significant digits in practice (2.71828).

(* Maths geek pun intended this time!)

### Re: Ruby related euler constant question

Posted:

**Sat Aug 24, 2019 2:05 am**
by **wlangfor@uoguelph.ca**

Yep, I just have to find a practical solution.