fix bias
This program takes a range [min, max] and precision and calculates constants and information to be used in code performing calculations in this range using fixed-point integer math.
This is not an official Google product.
$ git clone ssh://git@stash.nestlabs.com:7999/user/fpc.git $ make $ ./fpc -g 30 1800 0.1 [PARAMETERS] min: 30 (30 requested) max: 1800 (1800 requested) precision: 0.0625 (0.1 requested) [CODE] code density: 62.5% offset: 0 code range: [480, 28800] [ENCODING] machine bit width: 16 (15 used) fractional bits: 4 integer bits: 11 use signed: no machine integer type: uint16_t Q notation: Qu12.4 [CONVERSION] #include <math.h> #include <stdint.h> // can lose precision, for display only double convert_to_double(uint16_t x) { if(x < UINT16_C(480) && x > UINT16_C(28800)) { return NAN; } return round(ldexp(x, -4) * 10) * 0.1; } $ make convert $ ./convert 480 600 10000 28800 480 -> 30 600 -> 37.5 10000 -> 625 28800 -> 1800
$ ./fpc -2^7 -l-p 2^-8 [PARAMETERS] min: -128 (-128 requested) max: 127.99609375 (127.99609375 requested) precision: 0.00390625 (0.00390625 requested) ...
fpc has an expression evaluator built in to allow simple expressions!
fpc
(x)
x ^ y
x * y
x / y
x + y
x - y
l
h
p
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
Fixed-point Calculator
This program takes a range [min, max] and precision and calculates constants and information to be used in code performing calculations in this range using fixed-point integer math.
This is not an official Google product.
Try it!
Also, check this out:
fpchas an expression evaluator built in to allow simple expressions!(x)x ^ yx * y, divide:x / yx + y, subtraction:x - ylhp