OpenBullet2 icon indicating copy to clipboard operation
OpenBullet2 copied to clipboard

[Bug]: wrong compute

Open APT-ZERO opened this issue 2 years ago • 5 comments

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

APT-ZERO avatar Apr 17 '23 02:04 APT-ZERO

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.

DarkScripted avatar May 23 '23 03:05 DarkScripted

It's a bug and I guess the problem is that OB2 does not support int64 @DarkScripted

APT-ZERO avatar May 26 '23 22:05 APT-ZERO

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.

DarkScripted avatar May 27 '23 02:05 DarkScripted

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

DarkScripted avatar May 27 '23 13:05 DarkScripted

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.

openbullet avatar Aug 09 '23 11:08 openbullet