4 | %hide Data.List.replicate
6 | --------------------------------------------------------------------------------
7 | -- Fixed
8 | --------------------------------------------------------------------------------
10 | ||| The type of fixed-point fractional numbers.
16 | --------------------------------------------------------------------------------
17 | -- Show Utility
18 | --------------------------------------------------------------------------------
20 | ||| Render a fixed-point value to a string, with optional trailing zero chopping.
21 | |||
22 | ||| @chop whether to drop trailing zeros from the fractional part
23 | ||| @fa the fixed-point value, whose type index encodes resolution
24 | private
34 | chop
44 | where
50 | -1
54 | 0
56 | 1
71 | ""
83 | ""
90 | s
96 | ""
105 | --------------------------------------------------------------------------------
106 | -- Interfaces
107 | --------------------------------------------------------------------------------
139 | --------------------------------------------------------------------------------
140 | -- E0/Uni
141 | --------------------------------------------------------------------------------
143 | ||| +------------+---------------------+------+------------+
144 | ||| | Resolution | Scaling Factor | Type | show 12345 |
145 | ||| +============+=====================+======+============+
146 | ||| | E0 | 1\1 | Uni | 12345.0 |
147 | ||| +------------+---------------------+------+------------+
152 | --------------------------------------------------------------------------------
153 | -- E1/Deci
154 | --------------------------------------------------------------------------------
156 | ||| +------------+---------------------+------+------------+
157 | ||| | Resolution | Scaling Factor | Type | show 12345 |
158 | ||| +============+=====================+======+============+
159 | ||| | E1 | 1\10 | Deci | 1234.5 |
160 | ||| +------------+---------------------+------+------------+
165 | --------------------------------------------------------------------------------
166 | -- E2/Centi
167 | --------------------------------------------------------------------------------
169 | ||| +------------+---------------------+-------+------------+
170 | ||| | Resolution | Scaling Factor | Type | show 12345 |
171 | ||| +============+=====================+=======+============+
172 | ||| | E2 | 1\100 | Centi | 123.45 |
173 | ||| +------------+---------------------+-------+------------+
178 | --------------------------------------------------------------------------------
179 | -- E3/Milli
180 | --------------------------------------------------------------------------------
182 | ||| +------------+--------------------+-------+------------+
183 | ||| | Resolution | Scaling Factor | Type | show 12345 |
184 | ||| +============+====================+=======+============+
185 | ||| | E3 | 1\1000 | Milli | 12.345 |
186 | ||| +------------+--------------------+-------+------------+
191 | --------------------------------------------------------------------------------
192 | -- E4/TenthMilli
193 | --------------------------------------------------------------------------------
195 | ||| +------------+--------------------+------------+------------+
196 | ||| | Resolution | Scaling Factor | Type | show 12345 |
197 | ||| +============+====================+=======+=================+
198 | ||| | E4 | 1\10000 | TenthMilli | 1.2345 |
199 | ||| +------------+--------------------+------------+------------+
204 | --------------------------------------------------------------------------------
205 | -- E5/HundredthMilli
206 | --------------------------------------------------------------------------------
208 | ||| +------------+--------------------+------------------------+------------+
209 | ||| | Resolution | Scaling Factor | Type | show 12345 |
210 | ||| +============+====================+========================+============+
211 | ||| | E5 | 1\100000 | HundredthMilli | 0.12345 |
212 | ||| +------------+--------------------+------------------------+------------+
217 | --------------------------------------------------------------------------------
218 | -- E6/Micro
219 | --------------------------------------------------------------------------------
221 | ||| +------------+-------------------+-------+------------+
222 | ||| | Resolution | Scaling Factor | Type | show 12345 |
223 | ||| +============+===================+=======+============+
224 | ||| | E6 | 1\1000000 | Micro | 0.012345 |
225 | ||| +------------+-------------------+-------+------------+
230 | --------------------------------------------------------------------------------
231 | -- E7/DeciMicro
232 | --------------------------------------------------------------------------------
234 | ||| +------------+-------------------+-----------+------------+
235 | ||| | Resolution | Scaling Factor | Type | show 12345 |
236 | ||| +============+===================+===========+============+
237 | ||| | E7 | 1\10000000 | DeciMicro | 0.0012345 |
238 | ||| +------------+-------------------+-----------+------------+
243 | --------------------------------------------------------------------------------
244 | -- E8/CentiMicro
245 | --------------------------------------------------------------------------------
247 | ||| +------------+--------------------+------------+------------+
248 | ||| | Resolution | Scaling Factor | Type | show 12345 |
249 | ||| +============+====================+============+============+
250 | ||| | E8 | 1\100000000 | CentiMicro | 0.00012345 |
251 | ||| +------------+--------------------+------------+------------+
256 | --------------------------------------------------------------------------------
257 | -- E9/Nano
258 | --------------------------------------------------------------------------------
260 | ||| +------------+------------------+------+-------------+
261 | ||| | Resolution | Scaling Factor | Type | show 12345 |
262 | ||| +============+==================+======+=============+
263 | ||| | E9 | 1\1000000000 | Nano | 0.000012345 |
264 | ||| +------------+------------------+------+-------------+
269 | --------------------------------------------------------------------------------
270 | -- E10/DeciNano
271 | --------------------------------------------------------------------------------
273 | ||| +------------+-----------------+----------+--------------+
274 | ||| | Resolution | Scaling Factor | Type | show 12345 |
275 | ||| +============+=================+==========+==============+
276 | ||| | E10 | 1\10000000000 | DeciNano | 0.0000012345 |
277 | ||| +------------+-----------------+----------+--------------+
282 | --------------------------------------------------------------------------------
283 | -- E11/CentiNano
284 | --------------------------------------------------------------------------------
286 | ||| +------------+-----------------+-----------+---------------+
287 | ||| | Resolution | Scaling Factor | Type | show 12345 |
288 | ||| +============+=================+===========+===============+
289 | ||| | E11 | 1\100000000000 | CentiNano | 0.00000012345 |
290 | ||| +------------+-----------------+-----------+---------------+
295 | --------------------------------------------------------------------------------
296 | -- E12/Pico
297 | --------------------------------------------------------------------------------
299 | ||| +------------+-----------------+------+----------------+
300 | ||| | Resolution | Scaling Factor | Type | show 12345 |
301 | ||| +============+=================+======+================+
302 | ||| | E12 | 1\1000000000000 | Pico | 0.000000012345 |
303 | ||| +------------+-----------------+------+----------------+
308 | --------------------------------------------------------------------------------
309 | -- withResolution
310 | --------------------------------------------------------------------------------
312 | ||| Run a computation with the resolution available as an `Integer`.
313 | export