Calculations

I need to do the following calculation, give the startvalue is a string.

[code] // dim a as string = “271011240123456789232100”

// 271011240123456789232100 / 97 = 2793930310551100919918,5567010309278351[/code]

I need this resolution because I need to continue with the part behind the decimal point.


dim b as double = val(a)

When I do this, I get 271011240123456780000000 , so no chance to get the wanted result.

Maybe try Bob Delaney’s Decimal plugin which allows arbitrary large-value decimals: http://delaneyrm.com/DecimalPlugin.html

Thanks for the hint Paul and thanks Bob Delaney for providing the decimal datatype which should have been a standard type in Xojo I think.

This works:

[code] dim a as string = “271011240123456789232100”
DecSetPrecision(64)
DecSetScale(16)

dim da as Decimal
da = New Decimal(a)

dim db as decimal
db = da / 97

dim output as string = db.str // Result = “2793930310551100919918.5567010309278351” [/code]

Plugin = Decimal Plugin.rbx

Oh, I should have known. This old plugin is only 32-bit.
Think I must use this one .

Indeed.