Subversion Repositories wimsdev

Rev

Rev 475 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 reyssat 1
!if $wims_read_parm!=slib_header
2
 !goto proc
3
!endif
4
slib_title=make a representation of a physical quantity with a given number of significative digits
5
slib_parms=4\
6
1m, physical quantity\
7
3, number of significative digits\
8
 , optional: order of magnitude of the digit before the decimal dot; only valid if the quantity is dimensionless, just a number with no unit.\
9
 , optional: the desired physical unit to show (possibly a multiple or sub-multiple).
10
slib_author=Georges Khaznadar
11
slib_out=the physical quantity with the right number of digits, or a numeric value which would be equal to the result with the right number of digits.
12
slib_comment=the default means: 1 meter with three significative digits. The last example shows how the numeric value may lack some trailing zeros after the dot.<p><b>Known bug:</b><br>if the third parameter is used, the output may have a wrong syntax. Ensure that the resulting number has its decimal dot near its significant digits.
13
slib_example=1.2345A,2\
14
1.2V,5\
15
12,3\
16
12,3,4\
17
0.50A.h\
18
1800C,3,,A.h
19
!exit
20
 
21
:proc
22
slib_data=$wims_read_parm
23
!distribute items $slib_data  into slib_qty, slib_sig, slib_order, slib_wanted_unit
24
 
25
!default slib_qty=1m
26
!default slib_sig=3
27
!default slib_order=
28
!default slib_wanted_unit=
29
 
30
units_option=o
31
slib_u= !charcnt $slib_wanted_unit
32
!if $slib_u > 0
33
  slib_out= !exec units-filter $(slib_qty)#$(slib_sig):$(slib_wanted_unit)
34
!else
35
  slib_out= !exec units-filter $(slib_qty)#$(slib_sig)
36
!endif
37
slib_n= !charcnt $slib_order
38
!if $slib_n > 0
39
 slib_test= !eval $slib_out/1e$slib_order
40
 !if $slib_test <> NaN
41
  slib_out=$(slib_test)e$slib_order
42
 !endif
43
!endif
44
 
45