Platforms to show: All Mac Windows Linux Cross-Platform

/DataTypes/Big Number Test
Function:
Required plugins for this example: MBS DataTypes Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DataTypes/Big Number Test
This example is the version from Mon, 27th Nov 2016.
Project "Big Number Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open() list.ColumnAlignment(1) = List.AlignRight dim YearDays as BigNumberMBS = BigNumberMBS.NumberWithDouble(365.25) // days per year dim SecondsPerDay as BigNumberMBS = BigNumberMBS.NumberWithInteger(24*3600) dim LightSpeed as BigNumberMBS = BigNumberMBS.NumberWithInteger(299792458) // meter per second dim LightYear as BigNumberMBS = LightSpeed.Multiply(YearDays).Multiply(SecondsPerDay) List.AddRow "One light year", LightYear.Round.GetStringValue(10, false, 50)+" meter" dim DistanceToProximaCentauri as BigNumberMBS = BigNumberMBS.NumberWithDouble(4.2421).Multiply(LightYear) List.AddRow "Distance to Proxima Centauri", DistanceToProximaCentauri.Round.GetStringValue(10, false, 50)+" meter" dim DistanceToBarnardsStar as BigNumberMBS = BigNumberMBS.NumberWithDouble(5.9630).Multiply(LightYear) List.AddRow "Distance to Barnard's Star", DistanceToBarnardsStar.Round.GetStringValue(10, false, 50)+" meter" dim DistanceToWolf359 as BigNumberMBS = BigNumberMBS.NumberWithDouble(7.7825).Multiply(LightYear) List.AddRow "Distance to Wolf 359", DistanceToWolf359.Round.GetStringValue(10, false, 50)+" meter" dim DistanceToSirius as BigNumberMBS = BigNumberMBS.NumberWithDouble(8.5828).Multiply(LightYear) List.AddRow "Distance to Sirius", DistanceToSirius.Round.GetStringValue(10, false, 50)+" meter" dim DistanceToGalaxyCenter as BigNumberMBS = BigNumberMBS.NumberWithDouble(27.2).Multiply(1000).Multiply(LightYear) List.AddRow "Distance to center of Galaxy", DistanceToGalaxyCenter.Round.GetStringValue(10, false, 50)+" meter" dim DistanceToTriangulumGalaxy as BigNumberMBS = BigNumberMBS.NumberWithDouble(2.64).Multiply(1000000).Multiply(LightYear) List.AddRow "Distance to Triangulum Galaxy", DistanceToTriangulumGalaxy.Round.GetStringValue(10, false, 50)+" meter" dim DistanceToNGC4945Galaxy as BigNumberMBS = BigNumberMBS.NumberWithDouble(11.70).Multiply(1000000).Multiply(LightYear) List.AddRow "Distance to NGC 4945 Galaxy", DistanceToNGC4945Galaxy.Round.GetStringValue(10, false, 50)+" meter" // check maximum precision dim one as new BigNumberMBS(1) dim z as new BigNumberMBS(10) dim b as BigNumberMBS = one for i as integer = 1 to 120 dim d1 as BigNumberMBS = b - one dim d2 as BigNumberMBS = d1 + one dim s as string = b.GetStringValue(10, false, 200) if instr(s,"9") = 0 then List.AddRow "Exact "+str(i), s else Return // precise for 112 digits! end if b = b * z next End EventHandler
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS DataTypes Plugin.

The biggest plugin in space...




Links
MBS Xojo tutorial videos

Start Chat