1 |
W dniu nie, 10.09.2017 o godzinie 03∶05 +1200, użytkownik Kent Fredric |
2 |
napisał: |
3 |
> On Fri, 8 Sep 2017 13:19:23 +0200 |
4 |
> Michał Górny <mgorny@g.o> wrote: |
5 |
> |
6 |
> > a. getting wider review and some real-life testing before |
7 |
> > the specification is set in stone, and |
8 |
> |
9 |
> Any thoughts on a function that would represent a dotted-decimal style version |
10 |
> as a floating point string? |
11 |
> |
12 |
> eg: |
13 |
> |
14 |
> ver_float 0.1.0 -> 0.001 |
15 |
> ver_float 0.10.0 -> 0.010 |
16 |
> ver_float 0.100.0 -> 0.100 |
17 |
> |
18 |
> That's of course *the most* generic example I can offer, but seeing |
19 |
> this sort of transformation is commonly needed in the world of perl, I |
20 |
> thought maybe now is a good time to mention something. |
21 |
> |
22 |
> Sadly, its just the sort of idea that if done wrong, would be no use. |
23 |
> |
24 |
> For instance, sometimes you want: |
25 |
> |
26 |
> ver_float 0.1.0 -> 0.0010 |
27 |
> |
28 |
> Or |
29 |
> |
30 |
> ver_float 0.1.1 -> 0.001001 |
31 |
> |
32 |
> The two key things here is to know: |
33 |
> |
34 |
> 1. How many digits each position represents |
35 |
> 2. The maximum number of digits to represent |
36 |
> |
37 |
> So, some ideas in that regard are: |
38 |
> |
39 |
> ver_float ${INPUT} ${PRECISION} |
40 |
> |
41 |
> Where the values per position are fixed, so: |
42 |
> |
43 |
> ver_float 0.1 3 -> 0.001 |
44 |
> ver_float 0.1 2 -> INVALD # fidelity loss by truncation |
45 |
> ver_float 0.10 2 -> 0.01 # permitted because there's no fidelity loss by truncation |
46 |
> ver_float 0.100 1 -> 0.1 # permitted because there's no fidelity loss by truncation |
47 |
> ver_float 0.100 2 -> 0.10 |
48 |
> ver_float 0.100 3 -> 0.100 |
49 |
> ver_float 0.101 1 -> INVALID # fidelity loss by truncation |
50 |
> |
51 |
> ver_float 0.1 5 -> 0.00100 |
52 |
> ver_float 0.1.1 5 -> INVALID, need 6 digits to represent 0.1.1 |
53 |
> |
54 |
> ver_float 0.1.1 6 -> 0.001001 |
55 |
> |
56 |
> |
57 |
> Or say, |
58 |
> |
59 |
> ver_float ${INPUT} ${PATTERN} |
60 |
> |
61 |
> Where "pattern" is a string like 3-3-3 indicating how to map digits to numbers |
62 |
> |
63 |
> ver_float 0.1 3 -> 0.001 |
64 |
> ver_float 0.1 2 -> 0.01 |
65 |
> ver_float 0.1 1 -> 0.1 |
66 |
> ver_float 0.1.1 3 -> # INVALID, no map for '.1' |
67 |
> ver_float 0.1.1 3-3 -> 0.001001 |
68 |
> ver_float 0.1.10 3-3 -> 0.001010 |
69 |
> ver_float 0.1.10 2-2 -> 0.0110 |
70 |
> ver_float 0.10.10 2-2 -> 0.1010 |
71 |
> ver_float 0.100.10 2-2 -> # INVALID, can't map "100" into 2 characters |
72 |
> |
73 |
> Though I suspect you'd want both features ... |
74 |
> |
75 |
> ver_float ${INPUT} ${PATTERN} ${TRUNCATION_LENGTH} |
76 |
> |
77 |
> Because we do need packages where |
78 |
> |
79 |
> 0.123.10 means 0.1231 |
80 |
> |
81 |
> Either way, much of this is probably a time wasting bad idea. |
82 |
> |
83 |
> But I thought I'd just |
84 |
> |
85 |
> ( •_•) |
86 |
> |
87 |
> ( •_•)>⌐■-■ |
88 |
> |
89 |
> (⌐■_■) |
90 |
> |
91 |
> Float it by you. |
92 |
> |
93 |
|
94 |
I'm not sure if there's a serious proposal behind all this but I suppose |
95 |
it's all just perl-specific insanity that is of no value to everyone |
96 |
else. |
97 |
|
98 |
-- |
99 |
Best regards, |
100 |
Michał Górny |