[Bug]: wrong compute
Version of the software
0.2.5
Operating system
Windows 10
Browser / Native
Native
What happened?
A bug happened! When turn 1GB to Bytes, OB2 will return wrong answer.
Relevant LoliCode if needed
BLOCK:Compute
LABEL:gibtobyte
input = $"1 * 1024 * 1024 * 1024"
=> VAR @computeOutput
ENDBLOCK
Not a bug, the compute block in OB2 returns a float type, so you need to add the "round to integer" block in order to get the expected result.
It's a bug and I guess the problem is that OB2 does not support int64 @DarkScripted
It's a bug and I guess the problem is that OB2 does not support int64 @DarkScripted
Not sure what are you talking about because a calculator, a random webpage to convert GB to bytes and my response of adding the "Round to int" block give the exact same answer to that operation, which is 1073741824.
But I noticed that trying to convert 2GB or more will error with
[Executing block Compute] OverflowException: Value is either too large or too small for Type 'Int32'
which is a problem, but a different one.
I see now what you are talking about, OB2 does in fact do the operation right, but the issue is that it gets wrongly converted back to a string because it gets rounded for some reason. Converting it with dotnet's ToString() with the "F" formatting indicating to do it as a floating point with no scientific notations gives the proper result.
String test = @computeOutput.ToString("F"); // will return "1073741824.00"
LOG test
OB2 works with 32 bit integer and float types, I need to update it to support 64 bit long and double. I will do it sooner or later.