Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by shmem (Chancellor)
on Aug 23, 2017 at 19:45 UTC ( [id://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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1197890]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-20 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found