Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 21.3 ('London 2023')
Instant purchase and download via GumRoad!

COLUMN

Large, Big, and Bigger Numbers

Working with giant numbers

Issue: 21.3 (May/June 2023)
Author: Stefanie Juchmes
Author Bio: Stefanie studied computer science at the university in Bonn. She came in touch with Xojo due to the work of her brother-in-law and got a junior developer position in early 2019 at Monkeybread Software.
Article Description: No description available.
Article Length (in bytes): 7,398
Starting Page Number: 66
Article Number: 21307
Resource File(s):

Download Icon project-21307.zip Updated: 2023-05-05 09:39:18

Related Link(s): None

Excerpt of article text...

In this Spotlight article today I would like to introduce you to the Math section of the MBS Xojo plugins. This section was created for developers who need accurate and fast calculations in their applications. If you are a physicist, mathematician, chemist, or just a math enthusiast, you might be interested in this article.

One, Two, Overflow

Every number that we store in the computer has a certain length that is fixed. For example, an integer number in Xojo that runs in a 64-bit application can be 8 bytes (8 * 8 = 64 bits) long and have a range of values from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.

If we enter a value that is not in this range, an overflow will occur and a wrong number will be returned as the result (see Figure 1). Such an overflow can have fatal consequences that must be avoided if you can get results that extend beyond this range. If we use a UInteger we have at least a coverage of positive integers up to 18,446,744,073,709,551,615 but even this is sometimes not enough.

For decimal numbers we have two different approaches. On the one hand, the fixed point numbers like the type Currency which allow a maximum of four decimal places and thus go from a range of -922337203685477.5808 to 922337203685477.5807. Here the decimal point sits in a fixed place and cannot be moved.

Or we have floating point numbers. These have an enormously high range width with numbers that range between ?1.79769313486231570814527423731704357e+308 as a double. But here we have another problem, because they usually cannot be represented exactly. For example, if we have the number 6.1, it will be displayed as 6.0999999999999996 in the debugger, which can lead to rounding errors in calculations and can have catastrophic consequences (see Figure 2). But what can you do if you need this accuracy?

...End of Excerpt. Please purchase the magazine to read the full article.