Book Image

DART Cookbook

By : Ivo Balbaert
Book Image

DART Cookbook

By: Ivo Balbaert

Overview of this book

Table of Contents (18 chapters)
Dart Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Improving performance in numerical computations


Unlike Java and C#, who have dedicated 8, 16, 32, and 64 bit signed and unsigned integer types, and 32-bit and 64-bit floats, Dart does not have bounded integer types or 32-bit floating point number types; it only has two numeric types, int (an arbitrarily sized integer) and double (conforming to the IEEE-754 spec), and their super type num. This was done to make the language more dynamic and easier to learn and use. However, the Dart VM does a good job of inferring the range of integers, and optimizes whenever possible. Here, we provide a number of discussions and tips to give your code the highest performance possible when it involves numerical computing.

How to do it...

The VM uses three integer types internally and switches between them behind the scenes as numbers grow and shrink in size. They are as follows:

  • smi (small integer): You can think of this integer type as being 32 bit on a 32-bit machine and 64 bit on a 64-bit machine

  • mint (medium...