Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #124 (closed defect: fixed)

Opened 2 years ago

Last modified 10 months ago

E,e format specifier is not supported

Reported by: larsivi Assigned to: kris
Priority: major Milestone: 0.99.4
Component: Tango Version:
Keywords: Cc:

Description

See example/formatspec.d

Change History

12/18/06 16:28:10 changed by kris

  • milestone changed from 0.9 to 1.0.

This will have be postponed a bit

03/02/07 19:09:52 changed by kris

  • status changed from new to assigned.

03/05/07 01:24:44 changed by kris

Asked John Chapman to resolve this

(follow-up: ↓ 5 ) 08/01/07 11:21:28 changed by Deewiant

To fix, combine the fix for Ticket 555 with changing the check in tango.text.convert.Layout.floater from:

                if (parse2(format, places) is 'e')
                    scientific = true;

To:

                if ((parse2(format, places) ^ ('a' - 'A')) is 'e')
                    scientific = true;

Or whatever else to check for both upper and lower case 'e'.

(in reply to: ↑ 4 ) 08/01/07 12:35:13 changed by Deewiant

Replying to Deewiant:

                if ((parse2(format, places) ^ ('a' - 'A')) is 'e')

Er, make that

                if ((parse2(format, places) | ('a' ^ 'A')) is 'e')

08/01/07 13:16:43 changed by Deewiant

In addition to the upper case check (forget about Ticket #555), there's a problem with the "round up a bit" part in tango.text.convert.Float.format:

        // don't scale if zero
        if (x > 0.0)
           {
           // round up a bit (should do even/odd test?)
           x += 0.5 / pow10 (decimals);

I'm not even sure why the rounding is there, but I'm assuming it's important so I'd just add "if (!scientific)" prior to it, otherwise it messes stuff up completely with small values, for instance:

	Stdout.formatln("{:e4}", 0.01); // outputs 0.1005e-01
	Stdout.formatln("{:e4}", 0.0001); // outputs 0.1500e-03
	Stdout.formatln("{:e}", 0.0001); // outputs 0.51e-02, note: same value as above

Other than that, as far as I can tell, everything's fine.

11/25/07 02:10:44 changed by kris

  • status changed from assigned to closed.
  • resolution set to fixed.
  • milestone changed from 1.0 to 0.99.4.

fixed in [2927]

Thanks, larsivi