____ ____ ____ ____ 
||n |||i |||m |||f ||
||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|

	

the nimf guide : numbers

Numbers are the building blocks of all programing languages, and nimf is no exception. Everything in nimf is a number, with the exception of word names (which eventually down the programming line do get converted to numbers, but the nimf source code treats them as strings in golang).

Any time a number is encountered in nimf it gets added to the stack, as you can see in the following example:


12 35 .s
126 .s

Which produces the following output:


<2>[12 35] <3>[12 35 126]

What is a Number?

In nimf, the following are all numbers:

104 is clearly a number, and will get added to the top of the stack. As you will see in the next section of this guide, character literals are also numbers. `h will put the number 104 on the stack. So, in effect, the first two examples are identical to the system and a bit of syntactic sugar allows you to view one as a character in your source code.

The final example, the string 'hello, world' at first doesn't seem like a number. Which is true, it is not a single number... it is 13 separate numbers. They don't go on the stack like normal numbers though, they get stored to a special buffer in memory for strings. However, they are still stored as the numerical values of their characters, just like `h was. You can read more about the intricacies of strings in the strings section of this guide. The " words that surround a string are not numbers though, they are words that let the interpreter know that a string is being entered.

What isn't a Number?

Words are not numbers. For purposes of this discussion, a word in nimf is anything that is not a number as defined above. Not all words are known to the interpreter, but anything that is not a number gets treated as a word, and if the word is not known then an error will be thrown.

Because nimf only knows numbers as integers (whole numbers) a floating point number like 123.2789 is considred a word. However, a negative number like -123 is perfectly understood by the interreter to be a number.

What Are Numbers Used For?

Since numbers are the building blocks of all nimf programs they are used for just about everything.

The nimf interpreter's builtins mostly focus on dealing with numbers via arithmetic opperations, or manipulating numbers on the stack.