Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34710 > unrolled thread
| Started by | Roedy Green <inquiry@mindprod.com> |
|---|---|
| First post | 2016-06-28 21:34 -0700 |
| Last post | 2016-07-03 20:57 +0000 |
| Articles | 20 on this page of 160 — 12 participants |
Back to article view | Back to comp.lang.java.programmer
missing import java.lang.Comparable Roedy Green <inquiry@mindprod.com> - 2016-06-28 21:34 -0700
Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-06-29 05:56 +0000
Re: missing import java.lang.Comparable Roedy Green <inquiry@mindprod.com> - 2016-06-28 23:59 -0700
Re: missing import java.lang.Comparable Matthias Wiehl <mw@kwarg.de> - 2016-06-29 09:52 +0200
Re: missing import java.lang.Comparable Roedy Green <inquiry@mindprod.com> - 2016-06-29 01:16 -0700
Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-06-29 06:38 -0700
Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-06-30 13:24 +0000
Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-06-30 06:37 -0700
Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-30 10:19 -0400
Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-06-30 07:47 -0700
Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-30 11:17 -0400
Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-06-30 18:23 +0000
Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-30 15:24 -0400
Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-06-30 12:47 -0700
Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-30 16:38 -0400
Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-06-30 21:09 +0000
Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-01 06:45 +0000
Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-01 05:03 -0700
Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-03 20:46 +0000
Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-01 15:21 -0700
Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-03 21:10 +0000
Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-04 16:08 -0700
Program proof Mike Amling <mamling@chaff.us> - 2016-07-05 11:23 -0500
Re: Program proof Andreas Leitgeb <avl@logic.at> - 2016-07-05 18:08 +0000
Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-05 17:23 +0000
Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-05 14:28 -0700
Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-07 15:22 +0000
Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-07 11:44 -0400
Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-07 12:57 -0400
Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-07 18:29 +0000
[OT] Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-07 15:48 -0400
Re: [OT] Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-08 08:01 +0000
Re: [OT] Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-08 08:25 -0400
Re: [OT] Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-08 06:55 -0700
Re: [OT] Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-08 10:16 -0400
Re: [OT] Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-08 07:35 -0700
Re: [OT] Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-08 18:07 +0000
Re: [OT] Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-08 12:54 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-08 16:29 -0400
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-08 14:06 -0700
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-08 20:11 -0400
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-15 11:37 -0700
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-15 16:36 -0400
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-15 15:49 -0700
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-15 22:09 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-16 13:04 +0000
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-18 13:08 -0700
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-18 19:56 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-08 20:59 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-09 11:57 +0000
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-09 09:39 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-09 14:43 +0000
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-09 11:15 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-09 09:46 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-09 15:21 +0000
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-09 11:27 -0400
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-15 11:39 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-15 15:38 -0400
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-15 15:52 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-15 19:19 -0400
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-18 13:10 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-18 16:26 -0400
Re: [OT] Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-18 13:58 -0700
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-18 16:30 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-18 20:24 -0400
Re: [OT] Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-19 05:14 -0700
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-19 20:22 -0400
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-19 10:31 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-19 16:37 -0400
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-19 14:44 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-19 21:16 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-19 21:54 +0000
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-19 20:17 -0400
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-20 12:01 -0700
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-20 21:28 +0000
Re: [OT] Re: missing import java.lang.Comparable Gene Wirchenko <genew@telus.net> - 2016-07-20 16:14 -0700
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-19 20:18 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-19 21:33 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-19 21:56 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-19 23:47 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-22 23:31 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-23 10:24 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-23 21:26 -0400
Re: [OT] Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-23 19:23 -0700
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-23 23:08 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-24 10:44 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-24 10:44 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-20 16:04 -0400
Re: [OT] Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-20 14:51 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-20 22:57 -0400
Re: [OT] Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-21 11:38 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-21 15:57 -0400
Re: [OT] Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-21 13:45 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-21 21:00 -0400
Re: [OT] Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-22 15:28 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-22 19:34 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-22 23:36 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-23 10:25 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-23 10:58 +0000
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-23 09:32 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-22 23:34 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-23 10:25 -0400
Re: [OT] Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-23 17:04 -0700
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-24 10:46 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-23 21:23 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-24 10:47 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-22 23:40 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-18 20:02 -0400
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-18 20:26 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-18 20:35 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-18 19:59 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-08 23:36 +0000
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-08 20:09 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-09 12:51 +0000
Re: [OT] Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-09 09:15 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-09 14:30 +0000
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-09 09:44 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-09 14:37 +0000
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-09 11:14 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-09 20:09 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-10 01:11 +0000
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-09 21:52 -0400
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-10 10:34 +0000
Re: [OT] Re: missing import java.lang.Comparable Jerry Stuckle <jstucklex@attglobal.net> - 2016-07-08 21:03 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-08 20:32 -0400
Re: [OT] Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-11 05:30 -0700
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-11 16:26 +0000
Re: [OT] Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-11 13:56 -0400
Re: [OT] Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-11 10:59 -0700
Re: [OT] Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-11 15:09 -0400
Re: [OT] Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-11 13:44 -0700
Re: [OT] Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-11 17:21 -0400
Re: [OT] Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-11 10:56 -0700
Re: [OT] Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-11 11:49 -0700
Re: [OT] Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-07-11 21:00 +0000
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-11 22:30 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-11 22:36 -0400
Re: [OT] Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-07-12 11:37 -0700
Re: [OT] Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-12 13:01 -0700
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-12 20:31 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-11 22:13 -0400
Re: [OT] Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-08 20:18 -0400
Re: [OT] Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-08 15:14 -0700
Re: [OT] Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-08 17:59 +0000
Re: [OT] Re: missing import java.lang.Comparable Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-08 14:34 -0400
Re: [OT] Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-08 15:18 -0700
Re: [OT] Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-08 23:50 +0000
Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-07 13:18 -0700
Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-07 16:59 -0400
Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-07-08 15:05 -0700
Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-08 19:51 -0400
Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-07 17:07 -0400
Re: missing import java.lang.Comparable Martin Gregorie <martin@address-in-sig.invalid> - 2016-06-30 20:44 +0000
Re: missing import java.lang.Comparable Arne Vajhøj <arne@vajhoej.dk> - 2016-07-07 16:56 -0400
Re: missing import java.lang.Comparable a.laforgia@gmail.com - 2016-06-30 08:32 -0700
Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-06-30 08:59 -0700
Re: missing import java.lang.Comparable a.laforgia@gmail.com - 2016-06-30 09:06 -0700
Re: missing import java.lang.Comparable Eric Douglas <e.d.programmer@gmail.com> - 2016-06-30 09:35 -0700
Re: missing import java.lang.Comparable Lew <lewbloch@gmail.com> - 2016-06-30 11:18 -0700
Re: missing import java.lang.Comparable Andreas Leitgeb <avl@logic.at> - 2016-07-03 20:57 +0000
Page 8 of 8 — ← Prev page 1 2 3 4 5 6 7 [8]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2016-07-11 22:13 -0400 |
| Subject | Re: [OT] Re: missing import java.lang.Comparable |
| Message-ID | <nm1joi$1t3m$1@gioia.aioe.org> |
| In reply to | #34848 |
On 7/11/2016 8:30 AM, Eric Douglas wrote:
> On Friday, July 8, 2016 at 8:32:14 PM UTC-4, Arne Vajhøj wrote:
>> I don't think this example shows what you think it shows.
>>
>> It really shows that String.valueOf has an impact on the result.
>
> Converting to a String is what makes it work.
String.valueOf "round off" a little bit in the string result.
But I would not consider that a general solution.
> Whether it's the financial application dealing with fractions of
> pennies or an inventory management application which may have
> fractions depending on the unit of measure, I expect .0001 + .0002 to
> get exactly .0003.
Then you better use a data type that has this characteristic.
Use BigDecimal not double.
>
> Code:
> DecimalFormat myFormatter = new DecimalFormat("0.####################");
> String output;
> double a = .0002;
> double b = .0001;
> output = myFormatter.format(a + b);
> System.out.println(output);
> BigDecimal bda = new BigDecimal(String.valueOf(a));
> BigDecimal bdb = new BigDecimal(String.valueOf(b));
> bda = bda.add(bdb);
> output = myFormatter.format(bda.doubleValue());
> System.out.println(output);
> Output:
> 0.00030000000000000003
> 0.0003
>
> Code:
> DecimalFormat myFormatter = new DecimalFormat("0.####################");
> String output;
> double a = .0002;
> double b = .0001;
> output = myFormatter.format(a + b);
> System.out.println(output);
> BigDecimal bda = new BigDecimal(a);
> BigDecimal bdb = new BigDecimal(b);
> bda = bda.add(bdb);
> output = myFormatter.format(bda.doubleValue());
> System.out.println(output);
> Output:
> 0.00030000000000000003
> 0.00030000000000000003
Yes. But I think you want to do this:
DecimalFormat fmt = new DecimalFormat("0.####################");
BigDecimal bda = new BigDecimal("0.0002");
BigDecimal bdb = new BigDecimal("0.0001");
BigDecimal bdc = bda.add(bdb);
System.out.println(bdc);
System.out.println(fmt.format(bdc));
0.0003
0.0003
Arne
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2016-07-08 20:18 -0400 |
| Subject | Re: [OT] Re: missing import java.lang.Comparable |
| Message-ID | <nlpfsd$v3d$1@gioia.aioe.org> |
| In reply to | #34789 |
On 7/8/2016 10:35 AM, Eric Douglas wrote: > On Friday, July 8, 2016 at 10:16:23 AM UTC-4, Eric Sosman wrote: >> No one would want that. Also, no one experiences that (not in >> Java, at any rate). I get your point, though, that floating-point >> arithmetic can be surprising. > > I don't know if or how it happens with whole numbers offhand but it's > definitely an issue with decimals, and that is more than financials. > When you're trying to write an application that manages inventory > quantities and calculates the decimals as in to represent the > percentage of a can of paint, then this is a problem. Program: double > a = .0002; double b = .0001; System.out.println(a + b); Result: > 3.0000000000000003E-4 But that result is really correct. .0002 +/- some uncertainty + .0001 +/- some uncertainty is 3.0000000000000003E-4 +/- some uncertainty But maybe your inventory system do not work with built in uncertainty. Point being that in this case you should not use floating point either. Every time you think about using float and double to store some data always ask whether values has uncertainty. If not drop float/double and start looking at something else (maybe BigDecimal). Arne
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2016-07-08 15:14 -0700 |
| Subject | Re: [OT] Re: missing import java.lang.Comparable |
| Message-ID | <5e9436ef-e6c6-4d35-b47d-969060c3490a@googlegroups.com> |
| In reply to | #34786 |
Eric Douglas wrote: > I'd prefer if Java did normal math by default with a custom class to do floating point math Java does do normal math by default. Have you heard of the IEEE? > instead of the other way around. WTF? > Why, if you add 1 + 1 using double type values would you want the result to be 1.99999999999998? Since that doesn't happen, it's a moot question. Do you have any clue how IEEE floating-point math works? Or why? Even if you think you do, and your post strongly indicates otherwise, you should read https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html > It is tedious to do normal application math by converting the double to a String and passing it into a BigDecimal. Again, WTF? Why would you ever do that? Wouldn't you just use https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html#BigDecimal-double- for those rare times when you need the precision and accuracy of 'BigDecimal'? > Primitives are sort of Objects now. Perhaps you can't make a List<float> but float and Float are interchangeable and you can make a List<Float>. Wrong. 'Float' and 'float' are not interchangeable. They are mutually convertible, with restrictions, but that is not at all the same thing. What you clearly fail to realize, Eric, is that computers are a limited-precision instrument in their native maths. 'double' and 'float' are not infinitely precise, and they aren't real numbers. That means that numerical computation with these types is physically limited to be inaccurate in general. You can't fight physics. So please study up on this stuff. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Date | 2016-07-08 17:59 +0000 |
| Subject | Re: [OT] Re: missing import java.lang.Comparable |
| Message-ID | <slrnnnvqfo.456.avl@login.logic.tuwien.ac.at> |
| In reply to | #34785 |
Eric Sosman <esosman@comcast-dot-net.invalid> wrote: > On 7/8/2016 4:01 AM, Andreas Leitgeb wrote: >> Eric Sosman <esosman@comcast-dot-net.invalid> wrote: >>> On 7/7/2016 2:29 PM, Andreas Leitgeb wrote: >>>> Eric Sosman <esosman@comcast-dot-net.invalid> wrote: >>>>> [...] >>>>> (which always seems to be the most irritating situation), I go ahead and >>>>> write it out. And gnash my teeth, and tilt at other windmills instead. >>>> Its not like we had much of a choice besides "write it out & gnash teeth"... >>>> "other windmills" ... also Java-related? >>> https://en.wikipedia.org/wiki/Tilting_at_windmills >> Looked at it, just to find the obvious meaning (as a reference to Don Quixote) >> confirmed. > Sorry; I thought perhaps I had erred by confronting an Austrian > with an English idiom. Well, tbh, I didn't really know the complete phrase, but as it mentioned windmills, but not also Netherlands or Paris/"Moulin Rouge", then it was a safe bet to assume a Don Quixote reference ;-) > (Sometimes the literal translation of an idiom is of no help at all, > and one must simply learn the meaning by rote. That's why "Take him > for a ride" means "Nimm ihn um die Ecke," or so I'm told, even though Some of these phrases also depend on context. If "Take him for a ride" appears in a Mafia-context, then it probably means something different, than if it comes up among friends/family while attending an amusement park. (that's at least, how I'd understand it) The German phrase is more likely: "Bring ihn um die Ecke!", which unambiguously implies a request to kill someone. With "Nimm" it sounds just odd, like the supposed killer already wanted to commit suicide himself and is asked to take someone else along his way... > I'd like it if > Java had unsigned arithmetic and if signed integer overflow threw an > exception instead of wrapping around silently and sneakily -- but that's > not going to happen. I'd like it if primitive types were more like > objects, so I could have things like a `List<float>'. These are things I don't really miss... There are some Collection-like classes for primitives in some 3rd party lib (I think by apache, but not sure). > I'd like to add > and multiply BigIntegers with `+' and `*'. d'accord > Occasionally I'd like to use > something like a `typedef' to address some of the issues covered in this > thread. obviously d'accord. > Instead, alas, I struggle against the problems I myself put in my > own path. Most of my troubles are self-inflicted, most of my windmills > are self-erected, and I tilt at them endlessly, or so it seems. My own > faults are more troublesome than Java's ... You're not alone...
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2016-07-08 14:34 -0400 |
| Subject | Re: [OT] Re: missing import java.lang.Comparable |
| Message-ID | <nlornu$jcr$1@dont-email.me> |
| In reply to | #34799 |
On 7/8/2016 1:59 PM, Andreas Leitgeb wrote:
> Eric Sosman <esosman@comcast-dot-net.invalid> wrote:
>> [...]
>> (Sometimes the literal translation of an idiom is of no help at all,
>> and one must simply learn the meaning by rote. That's why "Take him
>> for a ride" means "Nimm ihn um die Ecke," or so I'm told, even though
>[...]
> The German phrase is more likely: "Bring ihn um die Ecke!", which
> unambiguously implies a request to kill someone. With "Nimm" it
> sounds just odd, like the supposed killer already wanted to commit
> suicide himself and is asked to take someone else along his way...
There's always *something* to undo the untutored (me) ...
http://dilbert.com/strip/1991-11-07
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2016-07-08 15:18 -0700 |
| Subject | Re: [OT] Re: missing import java.lang.Comparable |
| Message-ID | <b5f0b69e-f4af-4f1a-9372-57e1b815ce3b@googlegroups.com> |
| In reply to | #34799 |
Andreas Leitgeb wrote: > Some of these phrases also depend on context. If "Take him for a ride" > appears in a Mafia-context, then it probably means something different, > than if it comes up among friends/family while attending an amusement > park. (that's at least, how I'd understand it) > > The German phrase is more likely: "Bring ihn um die Ecke!", which > unambiguously implies a request to kill someone. With "Nimm" it > sounds just odd, like the supposed killer already wanted to commit > suicide himself and is asked to take someone else along his way... In American idiom "to take someone for a ride" almost always means "to cheat someone". The "Mafia" meaning is in disuse, although still listed in the dictionary. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Date | 2016-07-08 23:50 +0000 |
| Subject | Re: [OT] Re: missing import java.lang.Comparable |
| Message-ID | <slrnno0f2d.456.avl@login.logic.tuwien.ac.at> |
| In reply to | #34807 |
Lew <lewbloch@gmail.com> wrote: > Andreas Leitgeb wrote: >> Some of these phrases also depend on context. If "Take him for a ride" >> appears in a Mafia-context, then it probably means something different, >> than if it comes up among friends/family while attending an amusement >> park. (that's at least, how I'd understand it) > In American idiom "to take someone for a ride" almost always means > "to cheat someone". Thanks, I didn't know that meaning.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2016-07-07 13:18 -0700 |
| Message-ID | <d2a61a33-3ac2-42bf-8806-78888a81edd8@googlegroups.com> |
| In reply to | #34770 |
Andreas Leitgeb wrote: > Lewwrote: > > It is the full name. The simple name is an abbreviation. > > I don't dispute that at all. > > I just find it a pity, that in Java (as of now) the simple name > is the *only* possible abbreviation for a full name. > > I'd prefer to be able to choose an abbreviation on my own, > based on how the foreign class name fits better into my local > context. > > By "coincidence" (or "as a dead give away") that would then also > allow to abbreviate more than one among namesake classes from > different packages. > > I'd even go one step further: I'd also like to set up names > as alias for a parameterized generic class like List<String>. > Especially with nested Maps that could make code much more > readable. > > And then again, I know that posting it here is about as > effective as praying to some deity ;-) (So just consider > it as some kind of smalltalk and chill.) That's a heck of a lot of machinery for a corner case. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2016-07-07 16:59 -0400 |
| Message-ID | <nlmfqt$125a$3@gioia.aioe.org> |
| In reply to | #34749 |
On 7/1/2016 6:21 PM, Lew wrote: > On Thursday, June 30, 2016 at 11:45:52 PM UTC-7, Andreas Leitgeb wrote: >> Imho, Java lacks a feature that would allow one do assign local >> aliases for fully qualified class names. something like: >> import java.awt.List as AwtList; >> >> I seem to remember that other languages with hierarchical >> namespaces do have such a feature. > > Or you could just use the FQN for one of the conflicting types. Whatever is the big effing deal about that? It could make ones code look like Stefan's code ... :-) Arne
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2016-07-08 15:05 -0700 |
| Message-ID | <32d9a2ef-01d5-47ff-9fe6-46df87240bcf@googlegroups.com> |
| In reply to | #34778 |
On Thursday, July 7, 2016 at 1:59:20 PM UTC-7, Arne Vajhøj wrote: > On 7/1/2016 6:21 PM, Lew wrote: > > On Thursday, June 30, 2016 at 11:45:52 PM UTC-7, Andreas Leitgeb wrote: > >> Imho, Java lacks a feature that would allow one do assign local > >> aliases for fully qualified class names. something like: > >> import java.awt.List as AwtList; > >> > >> I seem to remember that other languages with hierarchical > >> namespaces do have such a feature. > > > > Or you could just use the FQN for one of the conflicting types. Whatever is the big effing deal about that? > > It could make ones code look like Stefan's code ... No, because I said to use the FQN for *one* of the *conflicting* types. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2016-07-08 19:51 -0400 |
| Message-ID | <nlpea1$ta7$1@gioia.aioe.org> |
| In reply to | #34805 |
On 7/8/2016 6:05 PM, Lew wrote: > On Thursday, July 7, 2016 at 1:59:20 PM UTC-7, Arne Vajhøj wrote: >> On 7/1/2016 6:21 PM, Lew wrote: >>> On Thursday, June 30, 2016 at 11:45:52 PM UTC-7, Andreas Leitgeb wrote: >>>> Imho, Java lacks a feature that would allow one do assign local >>>> aliases for fully qualified class names. something like: >>>> import java.awt.List as AwtList; >>>> >>>> I seem to remember that other languages with hierarchical >>>> namespaces do have such a feature. >>> >>> Or you could just use the FQN for one of the conflicting types. Whatever is the big effing deal about that? >> >> It could make ones code look like Stefan's code ... > > No, because I said to use the FQN for *one* of the *conflicting* types. What was the next non-empty line after the last line you quoted? Arne
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2016-07-07 17:07 -0400 |
| Message-ID | <nlmgap$139j$1@gioia.aioe.org> |
| In reply to | #34742 |
On 7/1/2016 2:45 AM, Andreas Leitgeb wrote:
> Imho, Java lacks a feature that would allow one do assign local
> aliases for fully qualified class names. something like:
> import java.awt.List as AwtList;
>
> I seem to remember that other languages with hierarchical
> namespaces do have such a feature.
The following is valid C#:
using SysConsole = System.Console;
namespace E
{
public class Console
{
}
public class Program
{
public static void Main(string[] args)
{
SysConsole.WriteLine("Testing");
SysConsole.ReadKey();
}
}
}
Arne
[toc] | [prev] | [next] | [standalone]
| From | Martin Gregorie <martin@address-in-sig.invalid> |
|---|---|
| Date | 2016-06-30 20:44 +0000 |
| Message-ID | <nl40bl$apo$1@dont-email.me> |
| In reply to | #34736 |
On Thu, 30 Jun 2016 15:24:49 -0400, Eric Sosman wrote: > Java's packages serve (among other things) as namespaces. There's > no reason not to use them as such. > Agreed, and using domain names as the first two terms of the package name is a pretty good way of keeping the namespaces from different developer groups distinct. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2016-07-07 16:56 -0400 |
| Message-ID | <nlmfmg$125a$2@gioia.aioe.org> |
| In reply to | #34726 |
On 6/30/2016 10:19 AM, Eric Sosman wrote: > On 6/30/2016 9:37 AM, Eric Douglas wrote: >> On Thursday, June 30, 2016 at 9:24:14 AM UTC-4, Martin Gregorie wrote: >>>> »No.« only in the special case that you do not have a »System.class« >>>> file in your directory. >>>> >>> s/you do not have/you have/ >> >> Right, you should need an import statement for anything in java.lang >> if you use their class names for one of your classes. >> I have a unique identifier in front of all my class names. > > Isn't that what the package name is for? It is what package names and the convention of only importing single classes not entire packages with * is for. But since java.lang is implicit wildcard imported, then I would consider class names in that to be a special case and try to avoid. Arne
[toc] | [prev] | [next] | [standalone]
| From | a.laforgia@gmail.com |
|---|---|
| Date | 2016-06-30 08:32 -0700 |
| Message-ID | <b5143d42-e99e-4e0c-bd8b-a5c399f79dd2@googlegroups.com> |
| In reply to | #34725 |
On Thursday, 30 June 2016 14:37:19 UTC+1, Eric Douglas wrote: [...] > I have a unique identifier in front of all my class names. Horrible. > I hate when classes have the same name. Inevitable. Packages are useful to disambuiguate.
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2016-06-30 08:59 -0700 |
| Message-ID | <278eb3d6-f4d9-4ad8-ba6d-9d792984b2de@googlegroups.com> |
| In reply to | #34729 |
On Thursday, June 30, 2016 at 11:32:23 AM UTC-4, a.laf...@gmail.com wrote:
> [...]
> > I have a unique identifier in front of all my class names.
>
> Horrible.
>
> > I hate when classes have the same name.
>
> Inevitable. Packages are useful to disambuiguate.
What would be horrible is not having a unique identifier...
package com.examples;
public class JTable extends javax.swing.JTable {
}
[toc] | [prev] | [next] | [standalone]
| From | a.laforgia@gmail.com |
|---|---|
| Date | 2016-06-30 09:06 -0700 |
| Message-ID | <5a40621a-035c-4a78-9973-7a95e412012f@googlegroups.com> |
| In reply to | #34730 |
On Thursday, 30 June 2016 16:59:49 UTC+1, Eric Douglas wrote: [...] > What would be horrible is not having a unique identifier... No, what is horrible is having a unique identifier in the name of a class, which is supposed to map a concept in your domain, period. You are mixing design and implementation details. A package defines a context for a class. That's all you need to disambiguate.
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2016-06-30 09:35 -0700 |
| Message-ID | <4ba619fc-d287-4835-abc1-a6b3b6f55253@googlegroups.com> |
| In reply to | #34731 |
On Thursday, June 30, 2016 at 12:06:29 PM UTC-4, a.laf...@gmail.com wrote: > No, what is horrible is having a unique identifier in the name of a class, which is supposed to map a concept in your domain, period. You are mixing design and implementation details. A package defines a context for a class. That's all you need to disambiguate. So you're saying you don't use import statements, you just fully qualify everything... and you ignored my sample...
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2016-06-30 11:18 -0700 |
| Message-ID | <4c310f67-34e3-4bf1-8578-0d4ae1c33b88@googlegroups.com> |
| In reply to | #34729 |
On Thursday, June 30, 2016 at 8:32:23 AM UTC-7, a.laf...@gmail.com wrote: > On Thursday, 30 June 2016 14:37:19 UTC+1, Eric Douglas wrote: > > [...] > > I have a unique identifier in front of all my class names. > > Horrible. > > > I hate when classes have the same name. > > Inevitable. Packages are useful to disambuiguate. The point here is not to name things the same as classes in 'java.lang', not to avoid simple name clashes altogether. People are missing the point. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Date | 2016-07-03 20:57 +0000 |
| Message-ID | <slrnnniv0t.456.avl@login.logic.tuwien.ac.at> |
| In reply to | #34725 |
Stefan Ram <ram@zedat.fu-berlin.de> wrote: > So, what I wrote was »You do NOT have to import > java.lang.System only in the special case that you do > NOT have a "System.class" file in your directory.«, > which is correct. Correct, but misleading, because you described the usual case of NOT having a local System.class as something "special". Technically, one can of course call anything "special" that has an extra condition attached to it, whatever the condition. Planet Saturn could be considered an example for the "special case" of a NON human-inhabited planet.
[toc] | [prev] | [standalone]
Page 8 of 8 — ← Prev page 1 2 3 4 5 6 7 [8]
Back to top | Article view | comp.lang.java.programmer
csiph-web