forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJs.Int.html
219 lines (191 loc) · 10.4 KB
/
Js.Int.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="../api_static/tomorrow-night.css">
<link rel="stylesheet" href="../api_static/style.css" type="text/css">
<script src="../api_static//highlight.pack.js"></script>
<script src="../api_static//script.js"></script>
<script>hljs.initHighlightingOnLoad();</script><meta charset="utf-8">
<link rel="previous" href="Js.Float.html">
<title>Js.Int</title>
</head>
<body>
<nav class="module-index"><ul><li><a href="Block.html">Block</a></li>
<li><a href="Bs.html">Bs</a></li>
<li><a href="Bs_dyn.html">Bs_dyn</a></li>
<li><a href="Bs_dyn_lib.html">Bs_dyn_lib</a></li>
<li><a href="Bs_obj.html">Bs_obj</a></li>
<li><a href="Bs_string.html">Bs_string</a></li>
<li><a href="Caml_array.html">Caml_array</a></li>
<li><a href="Caml_backtrace.html">Caml_backtrace</a></li>
<li><a href="Caml_basic.html">Caml_basic</a></li>
<li><a href="Caml_builtin_exceptions.html">Caml_builtin_exceptions</a></li>
<li><a href="Caml_bytes.html">Caml_bytes</a></li>
<li><a href="Caml_exceptions.html">Caml_exceptions</a></li>
<li><a href="Caml_float.html">Caml_float</a></li>
<li><a href="Caml_format.html">Caml_format</a></li>
<li><a href="Caml_gc.html">Caml_gc</a></li>
<li><a href="Caml_hash.html">Caml_hash</a></li>
<li><a href="Caml_int32.html">Caml_int32</a></li>
<li><a href="Caml_int64.html">Caml_int64</a></li>
<li><a href="Caml_io.html">Caml_io</a></li>
<li><a href="Caml_lexer.html">Caml_lexer</a></li>
<li><a href="Caml_md5.html">Caml_md5</a></li>
<li><a href="Caml_module.html">Caml_module</a></li>
<li><a href="Caml_obj.html">Caml_obj</a></li>
<li><a href="Caml_oo.html">Caml_oo</a></li>
<li><a href="Caml_oo_curry.html">Caml_oo_curry</a></li>
<li><a href="Caml_parser.html">Caml_parser</a></li>
<li><a href="Caml_primitive.html">Caml_primitive</a></li>
<li><a href="Caml_queue.html">Caml_queue</a></li>
<li><a href="Caml_string.html">Caml_string</a></li>
<li><a href="Caml_sys.html">Caml_sys</a></li>
<li><a href="Caml_utils.html">Caml_utils</a></li>
<li><a href="Caml_weak.html">Caml_weak</a></li>
<li><a href="Curry.html">Curry</a></li>
<li><a href="Dom.html">Dom</a></li>
<li><a href="Js.html">Js</a></li>
<li><a href="Js_array.html">Js_array</a></li>
<li><a href="Js_boolean.html">Js_boolean</a></li>
<li><a href="Js_cast.html">Js_cast</a></li>
<li><a href="Js_date.html">Js_date</a></li>
<li><a href="Js_dict.html">Js_dict</a></li>
<li><a href="Js_float.html">Js_float</a></li>
<li><a href="Js_global.html">Js_global</a></li>
<li><a href="Js_int.html">Js_int</a></li>
<li><a href="Js_int64.html">Js_int64</a></li>
<li><a href="Js_json.html">Js_json</a></li>
<li><a href="Js_math.html">Js_math</a></li>
<li><a href="Js_nativeint.html">Js_nativeint</a></li>
<li><a href="Js_null.html">Js_null</a></li>
<li><a href="Js_null_undefined.html">Js_null_undefined</a></li>
<li><a href="Js_obj.html">Js_obj</a></li>
<li><a href="Js_primitive.html">Js_primitive</a></li>
<li><a href="Js_re.html">Js_re</a></li>
<li><a href="Js_string.html">Js_string</a></li>
<li><a href="Js_typed_array.html">Js_typed_array</a></li>
<li><a href="Js_types.html">Js_types</a></li>
<li><a href="Js_undefined.html">Js_undefined</a></li>
<li><a href="Js_unsafe.html">Js_unsafe</a></li>
<li><a href="Node.html">Node</a></li>
<li><a href="Node_buffer.html">Node_buffer</a></li>
<li><a href="Node_child_process.html">Node_child_process</a></li>
<li><a href="Node_fs.html">Node_fs</a></li>
<li><a href="Node_module.html">Node_module</a></li>
<li><a href="Node_path.html">Node_path</a></li>
<li><a href="Node_process.html">Node_process</a></li></ul></nav>
<div class="navbar"><a class="pre" href="Js.Float.html" title="Js.Float">Previous</a>
<a class="up" href="Js.html" title="Js">Up</a>
</div>
<h1>Module <a href="type_Js.Int.html">Js.Int</a></h1>
<pre><span class="keyword">module</span> Int: <code class="type"><a href="Js_int.html">Js_int</a></code></pre><hr width="100%">
<pre><span id="VALtoExponential"><span class="keyword">val</span> toExponential</span> : <code class="type">int -> string</code></pre><div class="info ">
<div class="not-examples">
Formats an <code class="code">int</code> using exponential (scientific) notation
<p>
<b>Returns</b> a <code class="code">string</code> representing the given value in exponential notation<br>
<div class="tag"><b>Raises</b> <code>RangeError</code> if digits is not in the range [0, 20] (inclusive)<br>
</div><div class="tag"><b>See also</b> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential">MDN</a><br>
</div></div>
<div class="examples">
<pre class="example"><pre class="codepre"><code class="code">(* prints "7.7e+1" *)
let _ = Js.log @@ Js.Int.toExponential 77
</code></pre></pre></div>
</div>
<pre><span id="VALtoExponentialWithPrecision"><span class="keyword">val</span> toExponentialWithPrecision</span> : <code class="type">int -> digits:int -> string</code></pre><div class="info ">
<div class="not-examples">
Formats an <code class="code">int</code> using exponential (scientific) notation
<p>
<b>digits</b> specifies how many digits should appear after the decimal point. The
value must be in the range [0, 20] (inclusive).
<p>
<b>Returns</b> a <code class="code">string</code> representing the given value in exponential notation
<p>
The output will be rounded or padded with zeroes if necessary.<br>
<div class="tag"><b>Raises</b> <code>RangeError</code> if digits is not in the range [0, 20] (inclusive)<br>
</div><div class="tag"><b>See also</b> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential">MDN</a><br>
</div></div>
<div class="examples">
<pre class="example"><pre class="codepre"><code class="code">(* prints "7.70e+1" *)
let _ = Js.log @@ Js.Int.toExponentialWithPrecision 77 ~digits:2
(* prints "5.68e+3" *)
let _ = Js.log @@ Js.Int.toExponentialWithPrecision 5678 ~digits:2
</code></pre></pre></div>
</div>
<pre><span id="VALtoPrecision"><span class="keyword">val</span> toPrecision</span> : <code class="type">int -> string</code></pre><div class="info ">
<div class="not-examples">
Formats a <code class="code">int</code> using some fairly arbitrary rules
<p>
<b>Returns</b> a <code class="code">string</code> representing the given value in fixed-point (usually)
<p>
<code class="code">toPrecision</code> differs from <code class="code">toFixed</code> in that the former will format the number
with full precision, while the latter will not output any digits after the
decimal point.<br>
<div class="tag"><b>Raises</b> <code>RangeError</code> if digits is not in the range accepted by this function (what do you mean "vague"?)<br>
</div><div class="tag"><b>See also</b> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision">MDN</a><br>
</div></div>
<div class="examples">
<pre class="example"><pre class="codepre"><code class="code">(* prints "123456789" *)
let _ = Js.log @@ Js.Int.toPrecision 123456789
</code></pre></pre></div>
</div>
<pre><span id="VALtoPrecisionWithPrecision"><span class="keyword">val</span> toPrecisionWithPrecision</span> : <code class="type">int -> digits:int -> string</code></pre><div class="info ">
<div class="not-examples">
Formats an <code class="code">int</code> using some fairly arbitrary rules
<p>
<b>digits</b> specifies how many digits should appear in total. The
value must between 0 and some arbitrary number that's hopefully at least larger
than 20 (for Node it's 21. Why? Who knows).
<p>
<b>Returns</b> a <code class="code">string</code> representing the given value in fixed-point or scientific notation
<p>
The output will be rounded or padded with zeroes if necessary.
<p>
<code class="code">toPrecisionWithPrecision</code> differs from <code class="code">toFixedWithPrecision</code> in that the former
will count all digits against the precision, while the latter will count only
the digits after the decimal point. <code class="code">toPrecisionWithPrecision</code> will also use
scientific notation if the specified precision is less than the number for digits
before the decimal point.<br>
<div class="tag"><b>Raises</b> <code>RangeError</code> if digits is not in the range accepted by this function (what do you mean "vague"?)<br>
</div><div class="tag"><b>See also</b> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision">MDN</a><br>
</div></div>
<div class="examples">
<pre class="example"><pre class="codepre"><code class="code">(* prints "1.2e+8" *)
let _ = Js.log @@ Js.Int.toPrecisionWithPrecision 123456789 ~digits:2
(* prints "0.0" *)
let _ = Js.log @@ Js.Int.toPrecisionWithPrecision 0 ~digits:2
</code></pre></pre></div>
</div>
<pre><span id="VALtoString"><span class="keyword">val</span> toString</span> : <code class="type">int -> string</code></pre><div class="info ">
<div class="not-examples">
Formats a <code class="code">int</code> as a string
<p>
<b>Returns</b> a <code class="code">string</code> representing the given value in fixed-point (usually)<br>
<div class="tag"><b>See also</b> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString">MDN</a><br>
</div></div>
<div class="examples">
<pre class="example"><pre class="codepre"><code class="code">(* prints "123456789" *)
let _ = Js.log @@ Js.Int.toString 123456789
</code></pre></pre></div>
</div>
<pre><span id="VALtoStringWithRadix"><span class="keyword">val</span> toStringWithRadix</span> : <code class="type">int -> radix:int -> string</code></pre><div class="info ">
<div class="not-examples">
Formats an <code class="code">int</code> as a string
<p>
<b>radix</b> specifies the radix base to use for the formatted number. The
value must be in the range [2, 36] (inclusive).
<p>
<b>Returns</b> a <code class="code">string</code> representing the given value in fixed-point (usually)<br>
<div class="tag"><b>Raises</b> <code>RangeError</code> if radix is not in the range [2, 36] (inclusive)<br>
</div><div class="tag"><b>See also</b> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString">MDN</a><br>
</div></div>
<div class="examples">
<pre class="example"><pre class="codepre"><code class="code">(* prints "110" *)
let _ = Js.log @@ Js.Int.toStringWithRadix 6 ~radix:2
(* prints "deadbeef" *)
let _ = Js.log @@ Js.Int.toStringWithRadix 3735928559 ~radix:16
(* prints "2n9c" *)
let _ = Js.log @@ Js.Int.toStringWithRadix 123456 ~radix:36
</code></pre></pre></div>
</div>
</body></html>