Power Function Returns 0
Application Type
Traditional Web
Service Studio Version
11.10.21 (Build 41766)

Hello,

I'm trying to create a function with a quite complex calculation which contains below (values are for example)

Power((1+0.5833),-300)

However, the value will always returns to 0.
I've tried to change the Power value as below, and returns with a value

Power((1+0.5833),-5)
Result : 0.10050413755527

Is there any limitations with the function or something that I missed?


Thanks before

Hi Billy,

you do realise that a power of -300 will return a very very small number, right ?

So I'm guessing it just rounds to 0 because of the variable you put it in, what kind of variable do you put it in to display??  I think decimals, for example are limited to 8 digits, that's not enough.


If you put result in a text, you can see the power function works correctly.


If you have a local decimal variable, storing intermediary results of the calculation, and than continue next calculations with that, I don't really see a problem, see attached oml.

Dorine


QDRPowerCalculation.oml

Hi Dorine,

Yes, I do realize that. This is a complex formula and requires values such as that :(

I already tried to convert the value into text, but the value still returns to 0.

Converting the Power with DecimalToText() also doesn't work

have a look at the oml i shared, i see result of my calculations, it's not 0


On a side note, doing complex scientific calculations is not necessarily something you would want to do in Outsystems code.  Maybe make an extension in C# to do the heavy work ??

I've checked your OML, and tried on the traditional web module but the result still returns 0

Regarding on your side note, I think it would be inefficient since most calculations are using Power functions, but I will consider that.
It's kinda weird since I'm able to calculate the function with JS without any issues

PowerSample.oml

Ok,

So I didn't consider it was traditional.  My example is reactive client side logic, so that's javascript, that explains the difference between our tests.

So if you take another example as test, you can see that the client side calculation has much more digits than the server side calculation.

client side calculations in reactive

server side calculations in traditional

Outsystems documentation doesn't say anything about these limitations, unfortunately.  

I still think this might be work for a piece of math logic that is not necessarily written in low code, but made available with an extension or api or something.  I don't really understand your remark about performance.

Dorine

Thanks for the explanation regarding the difference.

For the remarks, it's not about the performance. I was considering using only the function from Outsystems, since the function is already available. I just confused by the same function yields different results.

Yes it's confusing, I would call it disappointing.

I would expect from a platform that the same function/action has the same result, no matter where you use it.  Or as a far behind second best, to have the limitations and differences well documented.

This is sadly not the only example where something acts different, dependent on where you do it.

Dorine

OutSystems has written a few words about it. 

At https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Data/Data_Types/Available_Data_Types you can see that OutSystems supports 8 digits for Decimals "The maximum number of digits in the decimal part is 8."

But at runtime, it's behaving like a C# application, which means that it will support more decimals at runtime, up to around 1^-28, which are 28 digits. see https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types

When saving those decimals to the database, it support those 8 digits.

Hans

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.