more int format - #182
Conversation
|
I really don't think it is useful to provide all this customizability. Putting effort in creating code that is optimized for people but solely read by compilers is imho not a big priority... |
|
It depends. If you work on custom int format, you want to have eg the mask for the different part avail. Also if you want to parse data to build other code from it, it may be better to parse the data faithfully. |
|
Anyhow, it's good it's not released, because I think it needs more thinking. I will try to have common interface-ish for all number AtomX classes. Even though for example you have only dec and hex representation for fp. I think I will go for a more complex internal field to represent the formatting, shared for long/int, and another shared for float/double . So IntegerLiteralFormat / FloatingPointLiteralFormat . |
|
But try to keep the default case (no formatting, decimal output) as efficient as possible - thx |
|
ok so here is what I want :
So for me it's best to have a record holding the representation params, including the enum base (hex, dec, bin, oct) , but have the already present methods visible on the JAtom to change the record to a new one. |
|
Much better this way. We can update the representation internally without changing the signature. |
|
fyi: I am on vacation next week - so no expectations towards me pls - thx :-) |
I did not expect you would review all the PRs so fast. gladly surprised. Also it's nice you took the formatting. Will help me focus on the important things. But yes, I don't expect anything, except that you take care of yourself during your vacations :) |
Features
Format class
A new
IntegerRepresentationrecord contains information to represent int and long in the code.Creation
A few default representation are available ; you are recommended to create your own.
Usage
JAtomInteger and JAtomLong have that new field. They extend a common class that allows to manipulate those fields internally, replacing the representation each time.
Formatting process
positiveSignis trueprefixUpperindicates if use upper or lower case prefixsuffixUpperindicates if use 'L' or 'l'separateEveryandseparateSizefields.Padding example
(those are the tests)
42 padded 5 is
(those are the tests)
Separate Format example
1000 decimal with format