I read the time from a string to a Ulong.
I calculate the elapsed time as a Ulong.
I calculate newtime as Ulong = time + elapsed.
All works fine, but when I use Numberformat(newtime,1,0) to convert to string there is an error.
If I repeatedly call the sub the calculated newtime is correct
but newtime converted to string is always the same.
Both a Double and a Ulong are 4 bytes.
Maybee my Ulong value is to large for a Double?
I created my own UlongFormat, is there a better way?
B4X:
Sub UlongFormat(Value As ULong) As String
Dim digits(10) As Byte
For count = 0 To 9
digits(count) = Value / Power(10,9-count)
Value = Value - digits(count) * Power(10,9-count)
digits(count) = digits(count)+48
Next
Return BC.StringFromBytes(digits)
End Sub
The problem is indeed with the implicit conversion to double when you call NumberFormat. It is possible to create a more efficient solution than the one you posted however it will not have any real advantage in this case.