Answered by:
conversor from base 10 to base 3that doesnt work with big numbers
Question

if i try small numbers it works all right but for example if i imput a 20 digits decimal number it doesnt convert it any way around this?
rey:
TextWindow.WriteLine("enter decimal number")
number= TextWindow.ReadNumber()
l=Text.GetLength(number)
TextWindow.WriteLine("lenght"+l)
dectotrin()
number=numero
trintodec()
number=numero
Goto rey
Sub dectotrin
'decimal a trinario
trinario=""
decimal=number
TextWindow.WriteLine(decimal)
While decimal>0
trin= Math.Remainder(decimal,3)
trinario= Text.Append(trin,trinario)
decimal=Math.Floor (decimal/3)
EndWhile
TextWindow.WriteLine("trinario "+trinario)
numero=trinario
EndSub
Sub trintodec
'trinario a decimal
decimal=""
trinario=number
l= Text.GetLength(trinario)
For i=1 To l
dec=Text.GetSubText(trinario,i,1)
decimal=decimal*3+dec
EndFor
TextWindow.WriteLine("decimal "+decimal)
numero=decimal
EndSub
Answers

Small Basic numbers are based on the 16 byte (128 bit) type called 'Decimal' (see here) with about 28 significant figures, much more than 999999999.
Most other languages C++ etc have the type called 'double' 8 byte  less precision (around 15 significant figures), but much larger and smaller numbers using exponents, e.g 1 google = 10^100 possible with a double (more than the number of atoms in the universe), but not a decimal.
There are exotic large number methods with high precision, but you usually have to write them yourself in the unusual situation where you need very large numbers and high precision (large number of significant figures).
 Edited by litdevModerator Wednesday, May 8, 2013 10:10 PM
 Marked as answer by antonio glez Thursday, May 9, 2013 12:11 AM
All replies


Small Basic numbers are based on the 16 byte (128 bit) type called 'Decimal' (see here) with about 28 significant figures, much more than 999999999.
Most other languages C++ etc have the type called 'double' 8 byte  less precision (around 15 significant figures), but much larger and smaller numbers using exponents, e.g 1 google = 10^100 possible with a double (more than the number of atoms in the universe), but not a decimal.
There are exotic large number methods with high precision, but you usually have to write them yourself in the unusual situation where you need very large numbers and high precision (large number of significant figures).
 Edited by litdevModerator Wednesday, May 8, 2013 10:10 PM
 Marked as answer by antonio glez Thursday, May 9, 2013 12:11 AM


You should note that internally EVERYTHING is binary and the size of numbers in any base is limited by the number of Bytes and Bits in binary and this inturn affects the size and precision of calculations. When we use the computer it converts the binary to letters, pictures or numbers decimal (base 10) or any other base octal (base 8), hex (base 16) etc purely for our convenience  how we display and use the numbers has no impact on the storage and calculations (always done in binary  this is fundamentally how microchips work).
So base 24 would also be stored and calculations done in binary internally. Using base 24 you would have to write the conversions to any supported number type, Decimal, Double, Byte etc or if you are very preficient with C++ for example you write your own  a lot of work.

You can do the simple calculations ( +  * / ) to about 29 digits, BUT the Math.Remainder() [and other Math...] functions do not go this far.
Try the following program
c=1 For i= 1To 60 c=c*3 l=text.GetLength(c) TextWindow.WriteLine(c+" :"+i+" :"+l) EndFor TextWindow.WriteLine("answer power length") TextWindow.WriteLine("") c="12345678901234567890123456789" c3=c/3 TextWindow.WriteLine(c) TextWindow.WriteLine(3*c3) TextWindow.WriteLine(c3)
If you try a base 26 in the above program, you see you can calculate 26^20 in this way
Jan [ WhTurner ] The Netherlands
 Edited by WhTurner33Editor Thursday, May 9, 2013 9:45 AM base 26

thanks for the lead now i understand the amazing capabilities of small basic:
i intend to make a program where a subroutine is aditition and another substraction with an array as sumand1digit[i]th and sumand2digit[i]th so i can get numbers as big as i want
then make a subroutine multiplication and division aslike but i was wondering if i can lead the computation out of a subroutine to a second subroutine outside the 1st and then return to the original subroutine
like the subroutine multiplication making a more basic subroutine of adition
 Edited by antonio glez Friday, May 10, 2013 4:09 PM