Re: Compact Number Formatting and Fraction Digits

2019-01-18 Thread Gunnar Morling
Aaah, ok, so I *only* must call setMaximumFractionDigits(). That's the
part I had missed so far; thanks!

--Gunnar

Am Fr., 18. Jan. 2019 um 00:35 Uhr schrieb Scott Palmer :
>
>
> On Jan 17, 2019, at 2:22 PM, Gunnar Morling  wrote:
>
> >> since you don’t actually want a minimum.
> >
> > I'd like to have 1 fractional digit unless it's 0:
> >
> > 1,000 -> 1K (*not* 1.0K)
> > 1,500 -> 1.5K
> >
> > --Gunnar
>
> That’s exactly what setting the maximum fraction digits to 1 does.
>
> Scott
>
>
> >
> >> Am Do., 17. Jan. 2019 um 19:15 Uhr schrieb Scott Palmer 
> >> :
> >>
> >>
> >> On Jan 17, 2019, at 12:42 PM, Gunnar Morling  wrote:
> >>
>  this could be a good value add to introduce an API [...]
> >>>
> >>> Should I file a JDK issue then (not sure I can even)?
> >>>
>  Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?
> >>>
> >>> That wouldn't achieve that there's no fraction digit(s) in case of
> >>> trailing 0s.
> >>
> >> Yes it does. I just tried. Don’t set a minimum fraction digits, since you 
> >> don’t actually want a minimum.
> >>
> >> Scott
> >>
> >>>
>  Am Do., 17. Jan. 2019 um 15:50 Uhr schrieb Scott Palmer 
>  :
> 
>  Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?
> 
> > On Jan 17, 2019, at 5:13 AM, Nishit Jain  wrote:
> >
> > Hi Gunnar,
> >
> > Currently there is no way to obtain the below expected behavior (to get 
> > 1K) when min fraction digit is set to non-zero value. I think that is 
> > not even expected when min fraction digits is set, but considering the 
> > objective of compact number formatting this could be a good value add 
> > to introduce an API which if set, truncates trailing fractional zeros 
> > while formatting output. This may need some thought process on its 
> > feasibility.
> >
> > Regards,
> > Nishit Jain
> >> On 17-01-2019 14:37, Gunnar Morling wrote:
> >> Hi,
> >>
> >> I took a look at the compact number formatting recently added in JDK 
> >> 12.
> >>
> >> There's setMinimumFractionDigits() to control the number of fractional
> >> digits, so that e.g. 1,500 can be formatted as 1.5K. That's great, but
> >> it also will format 1,000 as 1.0K. Is there a way to have fractional
> >> digits but remove trailing zeros, so that 1,500 and 1,000 would be
> >> formatted as 1.5K and 1K, respectively?


Re: Compact Number Formatting and Fraction Digits

2019-01-17 Thread Scott Palmer


On Jan 17, 2019, at 2:22 PM, Gunnar Morling  wrote:

>> since you don’t actually want a minimum.
> 
> I'd like to have 1 fractional digit unless it's 0:
> 
> 1,000 -> 1K (*not* 1.0K)
> 1,500 -> 1.5K
> 
> --Gunnar

That’s exactly what setting the maximum fraction digits to 1 does. 

Scott


> 
>> Am Do., 17. Jan. 2019 um 19:15 Uhr schrieb Scott Palmer :
>> 
>> 
>> On Jan 17, 2019, at 12:42 PM, Gunnar Morling  wrote:
>> 
 this could be a good value add to introduce an API [...]
>>> 
>>> Should I file a JDK issue then (not sure I can even)?
>>> 
 Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?
>>> 
>>> That wouldn't achieve that there's no fraction digit(s) in case of
>>> trailing 0s.
>> 
>> Yes it does. I just tried. Don’t set a minimum fraction digits, since you 
>> don’t actually want a minimum.
>> 
>> Scott
>> 
>>> 
 Am Do., 17. Jan. 2019 um 15:50 Uhr schrieb Scott Palmer 
 :
 
 Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?
 
> On Jan 17, 2019, at 5:13 AM, Nishit Jain  wrote:
> 
> Hi Gunnar,
> 
> Currently there is no way to obtain the below expected behavior (to get 
> 1K) when min fraction digit is set to non-zero value. I think that is not 
> even expected when min fraction digits is set, but considering the 
> objective of compact number formatting this could be a good value add to 
> introduce an API which if set, truncates trailing fractional zeros while 
> formatting output. This may need some thought process on its feasibility.
> 
> Regards,
> Nishit Jain
>> On 17-01-2019 14:37, Gunnar Morling wrote:
>> Hi,
>> 
>> I took a look at the compact number formatting recently added in JDK 12.
>> 
>> There's setMinimumFractionDigits() to control the number of fractional
>> digits, so that e.g. 1,500 can be formatted as 1.5K. That's great, but
>> it also will format 1,000 as 1.0K. Is there a way to have fractional
>> digits but remove trailing zeros, so that 1,500 and 1,000 would be
>> formatted as 1.5K and 1K, respectively?


Re: Compact Number Formatting and Fraction Digits

2019-01-17 Thread Gunnar Morling
> since you don’t actually want a minimum.

I'd like to have 1 fractional digit unless it's 0:

1,000 -> 1K (*not* 1.0K)
1,500 -> 1.5K

--Gunnar

Am Do., 17. Jan. 2019 um 19:15 Uhr schrieb Scott Palmer :
>
>
> On Jan 17, 2019, at 12:42 PM, Gunnar Morling  wrote:
>
> >> this could be a good value add to introduce an API [...]
> >
> > Should I file a JDK issue then (not sure I can even)?
> >
> >> Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?
> >
> > That wouldn't achieve that there's no fraction digit(s) in case of
> > trailing 0s.
>
> Yes it does. I just tried. Don’t set a minimum fraction digits, since you 
> don’t actually want a minimum.
>
> Scott
>
> >
> >> Am Do., 17. Jan. 2019 um 15:50 Uhr schrieb Scott Palmer 
> >> :
> >>
> >> Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?
> >>
> >>> On Jan 17, 2019, at 5:13 AM, Nishit Jain  wrote:
> >>>
> >>> Hi Gunnar,
> >>>
> >>> Currently there is no way to obtain the below expected behavior (to get 
> >>> 1K) when min fraction digit is set to non-zero value. I think that is not 
> >>> even expected when min fraction digits is set, but considering the 
> >>> objective of compact number formatting this could be a good value add to 
> >>> introduce an API which if set, truncates trailing fractional zeros while 
> >>> formatting output. This may need some thought process on its feasibility.
> >>>
> >>> Regards,
> >>> Nishit Jain
>  On 17-01-2019 14:37, Gunnar Morling wrote:
>  Hi,
> 
>  I took a look at the compact number formatting recently added in JDK 12.
> 
>  There's setMinimumFractionDigits() to control the number of fractional
>  digits, so that e.g. 1,500 can be formatted as 1.5K. That's great, but
>  it also will format 1,000 as 1.0K. Is there a way to have fractional
>  digits but remove trailing zeros, so that 1,500 and 1,000 would be
>  formatted as 1.5K and 1K, respectively?


Re: Compact Number Formatting and Fraction Digits

2019-01-17 Thread Scott Palmer


On Jan 17, 2019, at 12:42 PM, Gunnar Morling  wrote:

>> this could be a good value add to introduce an API [...]
> 
> Should I file a JDK issue then (not sure I can even)?
> 
>> Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?
> 
> That wouldn't achieve that there's no fraction digit(s) in case of
> trailing 0s.

Yes it does. I just tried. Don’t set a minimum fraction digits, since you don’t 
actually want a minimum. 

Scott

> 
>> Am Do., 17. Jan. 2019 um 15:50 Uhr schrieb Scott Palmer :
>> 
>> Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?
>> 
>>> On Jan 17, 2019, at 5:13 AM, Nishit Jain  wrote:
>>> 
>>> Hi Gunnar,
>>> 
>>> Currently there is no way to obtain the below expected behavior (to get 1K) 
>>> when min fraction digit is set to non-zero value. I think that is not even 
>>> expected when min fraction digits is set, but considering the objective of 
>>> compact number formatting this could be a good value add to introduce an 
>>> API which if set, truncates trailing fractional zeros while formatting 
>>> output. This may need some thought process on its feasibility.
>>> 
>>> Regards,
>>> Nishit Jain
 On 17-01-2019 14:37, Gunnar Morling wrote:
 Hi,
 
 I took a look at the compact number formatting recently added in JDK 12.
 
 There's setMinimumFractionDigits() to control the number of fractional
 digits, so that e.g. 1,500 can be formatted as 1.5K. That's great, but
 it also will format 1,000 as 1.0K. Is there a way to have fractional
 digits but remove trailing zeros, so that 1,500 and 1,000 would be
 formatted as 1.5K and 1K, respectively?


Re: Compact Number Formatting and Fraction Digits

2019-01-17 Thread Gunnar Morling
> this could be a good value add to introduce an API [...]

Should I file a JDK issue then (not sure I can even)?

> Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?

That wouldn't achieve that there's no fraction digit(s) in case of
trailing 0s. With min and max fraction digits set to 1, there'll
always be exactly one fraction digit. So having an API that'd allow to
remove trailing 0s would be very welcomed.

Btw. another suggestion I'd have is to document guarantees in terms of
thread-safety of CompactNumberFormat. It's a common mistake to use
SimpleDateFormat concurrently from multiple threads (although its docs
even state that this is incorrect). So CNF should at least document
its behaviour (or even allow for concurrent access, if feasible).

Am Do., 17. Jan. 2019 um 15:50 Uhr schrieb Scott Palmer :
>
> Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?
>
> > On Jan 17, 2019, at 5:13 AM, Nishit Jain  wrote:
> >
> > Hi Gunnar,
> >
> > Currently there is no way to obtain the below expected behavior (to get 1K) 
> > when min fraction digit is set to non-zero value. I think that is not even 
> > expected when min fraction digits is set, but considering the objective of 
> > compact number formatting this could be a good value add to introduce an 
> > API which if set, truncates trailing fractional zeros while formatting 
> > output. This may need some thought process on its feasibility.
> >
> > Regards,
> > Nishit Jain
> > On 17-01-2019 14:37, Gunnar Morling wrote:
> >> Hi,
> >>
> >> I took a look at the compact number formatting recently added in JDK 12.
> >>
> >> There's setMinimumFractionDigits() to control the number of fractional
> >> digits, so that e.g. 1,500 can be formatted as 1.5K. That's great, but
> >> it also will format 1,000 as 1.0K. Is there a way to have fractional
> >> digits but remove trailing zeros, so that 1,500 and 1,000 would be
> >> formatted as 1.5K and 1K, respectively?


Re: Compact Number Formatting and Fraction Digits

2019-01-17 Thread Scott Palmer
Wouldn’t this be accomplished with setMaximumFractionDigits(1) ?

> On Jan 17, 2019, at 5:13 AM, Nishit Jain  wrote:
> 
> Hi Gunnar,
> 
> Currently there is no way to obtain the below expected behavior (to get 1K) 
> when min fraction digit is set to non-zero value. I think that is not even 
> expected when min fraction digits is set, but considering the objective of 
> compact number formatting this could be a good value add to introduce an API 
> which if set, truncates trailing fractional zeros while formatting output. 
> This may need some thought process on its feasibility.
> 
> Regards,
> Nishit Jain
> On 17-01-2019 14:37, Gunnar Morling wrote:
>> Hi,
>> 
>> I took a look at the compact number formatting recently added in JDK 12.
>> 
>> There's setMinimumFractionDigits() to control the number of fractional
>> digits, so that e.g. 1,500 can be formatted as 1.5K. That's great, but
>> it also will format 1,000 as 1.0K. Is there a way to have fractional
>> digits but remove trailing zeros, so that 1,500 and 1,000 would be
>> formatted as 1.5K and 1K, respectively?


Re: Compact Number Formatting and Fraction Digits

2019-01-17 Thread Nishit Jain

Hi Gunnar,

Currently there is no way to obtain the below expected behavior (to get 
1K) when min fraction digit is set to non-zero value. I think that is 
not even expected when min fraction digits is set, but considering the 
objective of compact number formatting this could be a good value add to 
introduce an API which if set, truncates trailing fractional zeros while 
formatting output. This may need some thought process on its feasibility.


Regards,
Nishit Jain
On 17-01-2019 14:37, Gunnar Morling wrote:

Hi,

I took a look at the compact number formatting recently added in JDK 12.

There's setMinimumFractionDigits() to control the number of fractional
digits, so that e.g. 1,500 can be formatted as 1.5K. That's great, but
it also will format 1,000 as 1.0K. Is there a way to have fractional
digits but remove trailing zeros, so that 1,500 and 1,000 would be
formatted as 1.5K and 1K, respectively?

Thanks,

--Gunnar