Hi the problem i found is in both languages to find (spiderbasic and Purebasic)
if i force
Purebasic or Spiderbasic
Debug Str(((3*60)+30)/60)
both return 3 and not 3,5 it seems something to go wrong.
calculation problem
Re: calculation problem
What goes wrong, is that you are using the wrong function, please have a look at the "Remarks" section of the SB docs:
https://www.spiderbasic.com/documentati ... g/str.html
https://www.spiderbasic.com/documentati ... g/str.html
Re: calculation problem
it returns
Result: 100000000000000000
it kills a 1 in se last line
and some changes
Value.q = 2.522
Debug "Result: " + Str(Value)
Result: 3
Value.q = 2.22
Debug "Result: " + Str(Value)
Result: 2
Result: 100000000000000000
it kills a 1 in se last line
and some changes
Value.q = 2.522
Debug "Result: " + Str(Value)
Result: 3
Value.q = 2.22
Debug "Result: " + Str(Value)
Result: 2
Re: calculation problem
As hoerbie said, use the proper function...
Code: Select all
Debug StrD(((3*60)+30)/60)
Re: calculation problem
Sorry, I don't understand what you mean by
Paul directly posted the right function, that I thought you could find yourself from my last post:
https://www.spiderbasic.com/documentati ... /strd.html
So in clear words: to print out a decimal value you need to use the StrD() function.
But changing the function in your example will not do anything, because you are additionally using the wrong data type for your variable "Value". Please read and understand the section under "Variables declaration" and "Basic types":
https://www.spiderbasic.com/documentati ... ables.html
In clear words: your decimal value 2.522 is directly cut (or rounded) from SB or PB when you try to save it in a variable type like .q that only can handle non-decimal numbers. You need to use the .d type for decimal variables.
And as additional information: when you are now using the right type and function for your above example, you will find new problems, that SB or PB output a slightly different value than you put in the variable. This is also not a bug.
For this please read and understand the last section "Special information about Floats and Doubles" of the https://www.spiderbasic.com/documentati ... ables.html
And your new examples likeResult: 100000000000000000
it kills a 1 in se last line
can't work now because of two errors.Value.q = 2.522
Debug "Result: " + Str(Value)
Paul directly posted the right function, that I thought you could find yourself from my last post:
https://www.spiderbasic.com/documentati ... /strd.html
So in clear words: to print out a decimal value you need to use the StrD() function.
But changing the function in your example will not do anything, because you are additionally using the wrong data type for your variable "Value". Please read and understand the section under "Variables declaration" and "Basic types":
https://www.spiderbasic.com/documentati ... ables.html
In clear words: your decimal value 2.522 is directly cut (or rounded) from SB or PB when you try to save it in a variable type like .q that only can handle non-decimal numbers. You need to use the .d type for decimal variables.
And as additional information: when you are now using the right type and function for your above example, you will find new problems, that SB or PB output a slightly different value than you put in the variable. This is also not a bug.
For this please read and understand the last section "Special information about Floats and Doubles" of the https://www.spiderbasic.com/documentati ... ables.html