On Fri, 8 Sep 2017 13:19:23 +0200 Michał Górny <[email protected]> wrote:
> a. getting wider review and some real-life testing before
> the specification is set in stone, and
Any thoughts on a function that would represent a dotted-decimal style version
as a floating point string?
eg:
ver_float 0.1.0 -> 0.001
ver_float 0.10.0 -> 0.010
ver_float 0.100.0 -> 0.100
That's of course *the most* generic example I can offer, but seeing
this sort of transformation is commonly needed in the world of perl, I
thought maybe now is a good time to mention something.
Sadly, its just the sort of idea that if done wrong, would be no use.
For instance, sometimes you want:
ver_float 0.1.0 -> 0.0010
Or
ver_float 0.1.1 -> 0.001001
The two key things here is to know:
1. How many digits each position represents
2. The maximum number of digits to represent
So, some ideas in that regard are:
ver_float ${INPUT} ${PRECISION}
Where the values per position are fixed, so:
ver_float 0.1 3 -> 0.001
ver_float 0.1 2 -> INVALD # fidelity loss by truncation
ver_float 0.10 2 -> 0.01 # permitted because there's no fidelity loss
by truncation
ver_float 0.100 1 -> 0.1 # permitted because there's no fidelity loss
by truncation
ver_float 0.100 2 -> 0.10
ver_float 0.100 3 -> 0.100
ver_float 0.101 1 -> INVALID # fidelity loss by truncation
ver_float 0.1 5 -> 0.00100
ver_float 0.1.1 5 -> INVALID, need 6 digits to represent 0.1.1
ver_float 0.1.1 6 -> 0.001001
Or say,
ver_float ${INPUT} ${PATTERN}
Where "pattern" is a string like 3-3-3 indicating how to map digits to numbers
ver_float 0.1 3 -> 0.001
ver_float 0.1 2 -> 0.01
ver_float 0.1 1 -> 0.1
ver_float 0.1.1 3 -> # INVALID, no map for '.1'
ver_float 0.1.1 3-3 -> 0.001001
ver_float 0.1.10 3-3 -> 0.001010
ver_float 0.1.10 2-2 -> 0.0110
ver_float 0.10.10 2-2 -> 0.1010
ver_float 0.100.10 2-2 -> # INVALID, can't map "100" into 2 characters
Though I suspect you'd want both features ...
ver_float ${INPUT} ${PATTERN} ${TRUNCATION_LENGTH}
Because we do need packages where
0.123.10 means 0.1231
Either way, much of this is probably a time wasting bad idea.
But I thought I'd just
( •_•)
( •_•)>⌐■-■
(⌐■_■)
Float it by you.
pgpP52i6KANoq.pgp
Description: OpenPGP digital signature
