8.2 Numbers

The number type can be used to store signed integer and real numbers. The storage space for every number has full 64 bits, which means that you can use very large integers and very precise float numbers. The number type can theoretically store numbers ranging from 1.7*10^-308 to 1.7*10^308 although you will never need such huge numbers in practice.

You can also specify hexadecimal numbers by using the prefix $ or 0x, e.g.:

 
a = $FF     ; a = 255

Floating point numbers can also be specified by using the exponential notation, e.g.

 
a = 2.5e5   ; a = 2.5 * 10^5  => a = 250000

The 0 is optional for floating point values between -1 and 1. So the following code would also work:

 
a = .25 * 2 ; a = 0.5

Although Hollywood does not have separate data types for integer and floating point numbers, there is still the style-guide suggestion to suffix variables that are expected to hold floating point values with an exclamation mark. E.g.

 
a! = 3.14159265

This makes it easier to read your code because you know exactly which variables will get integer values only and which variables will get floating point values. Of course, you can use floating point values without the exclamation mark, but it is suggested that you use it.


Show TOC