Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^4: Math::Base - arithmetics with baseX integers (OP updated)

by shmem (Chancellor)
on Aug 23, 2017 at 19:45 UTC ( #1197890=note: print w/replies, xml ) Need Help??

in reply to Re^3: Math::Base - arithmetics with baseX integers (OP updated)
in thread Math::Base - arithmetics with baseX integers (updated)

That's only meaningful for base-2.

Well, that's how computers work, don't they... since the whole business of this convoluted module is only yielding the string representation of a value $n to base $b via a charset @c, while all calculations are carried out on the number/integer slots of its objects - it doesn't really calculate in base $b (no such machine except $base == 2) - the only thing is to find a good stringified representation of the underlying numbers, whilst not limiting the native number range.

So I guess the best way to go here is outlawing '-' from the valid chars array and using that as a prefix for negative numbers. That would reduce the maxbase to 90, which I deem not to be a big loss. Would that be a good way to go?

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^5: Math::Base - arithmetics with baseX integers (OP updated)
by no_slogan (Deacon) on Aug 24, 2017 at 16:09 UTC
    I feel like the signed representation makes the most sense, but whatev. If the object is to represent high bases in an inscrutable fashion, there are plenty of Unicode characters out there. If it's to map every printable ASCII string to an integer value, you could use a mixed radix approach where the first digit is (at most) base-94 and the rest are base-95. (There are 95 printable ASCII characters, you missed these: {|}~)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1197890]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2018-08-19 03:51 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (186 votes). Check out past polls.