mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	Update documentation to remove references of integers and real numbers.
Now there is only one kind of number.
This commit is contained in:
		| @@ -44,18 +44,8 @@ prefix notation. Janet also supports the remainder operator, or `%`, which retur | ||||
| the remainder of division. For example, `(% 10 3)` is 1, and `(% 10.5 3)` is | ||||
| 1.5. The lines that begin with `#` are comments. | ||||
|  | ||||
| Janet actually has two "flavors" of numbers; integers and real numbers. Integers are any | ||||
| integer value between -2,147,483,648 and 2,147,483,647 (32 bit signed integer). | ||||
| Reals are real numbers, and are represented by IEEE-754 double precision floating point | ||||
| numbers. That means that they can represent any number an integer can represent, as well | ||||
| fractions to very high precision. | ||||
|  | ||||
| Although real numbers can represent any value an integer can, try to distinguish between | ||||
| real numbers and integers in your program. If you are using a number to index into a structure, | ||||
| you probably want integers. Otherwise, you may want to use reals (this is only a rule of thumb). | ||||
|  | ||||
| Arithmetic operator will convert integers to real numbers if needed, but real numbers | ||||
| will not be converted to integers, as not all real numbers can be safely converted to integers. | ||||
| All janet numbers are IEEE 754 floating point numbers. They can be used to represent | ||||
| both integers and real numbers to a finite precision. | ||||
|  | ||||
| ## Numeric literals | ||||
|  | ||||
|   | ||||
| @@ -70,8 +70,8 @@ in macros. | ||||
|  | ||||
| ## Numbers | ||||
|  | ||||
| Janet numbers are represented by either 32 bit integers or | ||||
| IEEE-754 floating point numbers. The syntax is similar to that of many other languages | ||||
| Janet numbers are represented by IEEE-754 floating point numbers. | ||||
| The syntax is similar to that of many other languages | ||||
| as well. Numbers can be written in base 10, with | ||||
| underscores used to separate digits into groups. A decimal point can be used for floating | ||||
| point numbers. Numbers can also be written in other bases by prefixing the number with the desired | ||||
|   | ||||
| @@ -153,40 +153,30 @@ failure to return or error. | ||||
| * The `>>>` indicates unsigned right shift, as in Java. Because all integers in janet are | ||||
|   signed, we differentiate the two kinds of right bit shift. | ||||
|  | ||||
| * The 'im' suffix in the instruction name is short for immediate. The 'i' suffix is short for integer, | ||||
|   and the 'r' suffix is short for real. | ||||
| * The 'im' suffix in the instruction name is short for immediate. | ||||
|  | ||||
| ### Reference Table | ||||
|  | ||||
| | Instruction | Signature                   | Description                       | | ||||
| | ----------- | --------------------------- | --------------------------------- | | ||||
| | `add`       | `(add dest lhs rhs)`        | $dest = $lhs + $rhs               |  | ||||
| | `addi`      | `(addi dest lhs rhs)`       | $dest = $lhs +i $rhs              | | ||||
| | `addim`     | `(addim dest lhs im)`       | $dest = $lhs +i im                | | ||||
| | `addr`      | `(addr dest lhs rhs)`       | $dest = $lhs +r $rhs              | | ||||
| | `addim`     | `(addim dest lhs im)`       | $dest = $lhs + im                 | | ||||
| | `band`      | `(band dest lhs rhs)`       | $dest = $lhs & $rhs               | | ||||
| | `bnot`      | `(bnot dest operand)`       | $dest = ~$operand                 | | ||||
| | `bor`       | `(bor dest lhs rhs)`        | $dest = $lhs | $rhs               | | ||||
| | `bxor`      | `(bxor dest lhs rhs)`       | $dest = $lhs ^ $rhs               | | ||||
| | `call`      | `(call dest callee)`        | $dest = call($callee, args)       | | ||||
| | `clo`       | `(clo dest index)`          | $dest = closure(defs[$index])     | | ||||
| | `cmp`       | `(cmp dest lhs rhs)`        | $dest = janet\_compare($lhs, $rhs)  | | ||||
| | `cmp`       | `(cmp dest lhs rhs)`        | $dest = janet\_compare($lhs, $rhs)| | ||||
| | `div`       | `(div dest lhs rhs)`        | $dest = $lhs / $rhs               | | ||||
| | `divi`      | `(divi dest lhs rhs)`       | $dest = $lhs /i $rhs              | | ||||
| | `divim`     | `(divim dest lhs im)`       | $dest = $lhs /i im                | | ||||
| | `divr`      | `(divr dest lhs rhs)`       | $dest = $lhs /r $rhs              | | ||||
| | `divim`     | `(divim dest lhs im)`       | $dest = $lhs / im                 | | ||||
| | `eq`        | `(eq dest lhs rhs)`         | $dest = $lhs == $rhs              | | ||||
| | `eqi`       | `(eqi dest lhs rhs)`        | $dest = $lhs ==i $rhs             | | ||||
| | `eqim`      | `(eqim dest lhs im)`        | $dest = $lhs ==i im               | | ||||
| | `eqr`       | `(eqr dest lhs rhs)`        | $dest = $lhs ==r $rhs             | | ||||
| | `eqim`      | `(eqim dest lhs im)`        | $dest = $lhs == im                | | ||||
| | `err`       | `(err message)`             | Throw error $message.             | | ||||
| | `get`       | `(get dest ds key)`         | $dest = $ds[$key]                 | | ||||
| | `geti`      | `(geti dest ds index)`      | $dest = $ds[index]                | | ||||
| | `gt`        | `(gt dest lhs rhs)`         | $dest = $lhs > $rhs               | | ||||
| | `gti`       | `(gti dest lhs rhs)`        | $dest = $lhs \>i $rhs             | | ||||
| | `gtim`      | `(gtim dest lhs im)`        | $dest = $lhs \>i im               | | ||||
| | `gtr`       | `(gtr dest lhs rhs)`        | $dest = $lhs \>r $rhs             | | ||||
| | `gter`      | `(gter dest lhs rhs)`       | $dest = $lhs >=r $rhs             | | ||||
| | `gt`        | `(gt dest lhs rhs)`         | $dest = $lhs \> $rhs              | | ||||
| | `gtim`      | `(gtim dest lhs im)`        | $dest = $lhs \> im                | | ||||
| | `jmp`       | `(jmp label)`               | pc = label, pc += offset          | | ||||
| | `jmpif`     | `(jmpif cond label)`        | if $cond pc = label else pc++     | | ||||
| | `jmpno`     | `(jmpno cond label)`        | if $cond pc++ else pc = label     | | ||||
| @@ -198,10 +188,8 @@ failure to return or error. | ||||
| | `ldt`       | `(ldt dest)`                | $dest = true                      | | ||||
| | `ldu`       | `(ldu dest env index)`      | $dest = envs[env][index]          | | ||||
| | `len`       | `(len dest ds)`             | $dest = length(ds)                | | ||||
| | `lt`        | `(lt dest lhs rhs)`         | $dest = $lhs < $rhs               | | ||||
| | `lti`       | `(lti dest lhs rhs)`        | $dest = $lhs \<i $rhs             | | ||||
| | `ltim`      | `(ltim dest lhs im)`        | $dest = $lhs \<i im               | | ||||
| | `ltr`       | `(ltr dest lhs rhs)`        | $dest = $lhs \<r $rhs             | | ||||
| | `lt`        | `(lt dest lhs rhs)`         | $dest = $lhs \< $rhs              | | ||||
| | `ltim`      | `(ltim dest lhs im)`        | $dest = $lhs \< im                | | ||||
| | `mkarr`     | `(mkarr dest)`              | $dest = call(array, args)         | | ||||
| | `mkbuf`     | `(mkbuf dest)`              | $dest = call(buffer, args)        | | ||||
| | `mktab`     | `(mktab dest)`              | $dest = call(table, args)         | | ||||
| @@ -210,10 +198,8 @@ failure to return or error. | ||||
| | `mktup`     | `(mktup dest)`              | $dest = call(tuple, args)         | | ||||
| | `movf`      | `(movf src dest)`           | $dest = $src                      | | ||||
| | `movn`      | `(movn dest src)`           | $dest = $src                      | | ||||
| | `mul`       | `(mul dest lhs rhs)`        | $dest = $lhs * $rhs               | | ||||
| | `muli`      | `(muli dest lhs rhs)`       | $dest = $lhs \*i $rhs             | | ||||
| | `mulim`     | `(mulim dest lhs im)`       | $dest = $lhs \*i im               | | ||||
| | `mulr`      | `(mulr dest lhs rhs)`       | $dest = $lhs \*r $rhs             | | ||||
| | `mul`       | `(mul dest lhs rhs)`        | $dest = $lhs \* $rhs              | | ||||
| | `mulim`     | `(mulim dest lhs im)`       | $dest = $lhs \* im                | | ||||
| | `noop`      | `(noop)`                    | Does nothing.                     | | ||||
| | `push`      | `(push val)`                | Push $val on arg                  | | ||||
| | `push2`     | `(push2 val1 val3)`         | Push $val1, $val2 on args         | | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose