Commit Graph

26 Commits (f140d48e24aa8ed3a1ca57798f36a542db8bcfc7)

Author SHA1 Message Date
Jon Harper e470a5bb28 formatting, workaround bug for "%.0e" and "%.0f" on windows
On windows, the underlying formatting implementation
uses a precison of 6 when asked to do a precision of 0.
Improve the post-processing so that it doesn't fully break
the formatted number. The previous implementation would change
"1.00000" to "10000", and 1.00000e0 to 10000e0...

With this, windows has a different formatting for "%.0f" and "%.0e"
but at least it's the right number
2017-07-08 18:40:08 +02:00
Jon Harper 7c2e964fc9 formatting: fix exception when formatting the integer 0 using "%e" 2017-07-08 18:39:56 +02:00
Björn Lindqvist 7a9817aeb6 formatting.tests: conditioning some tests to pass on windows 2017-06-28 11:18:40 +02:00
John Benediktsson 0fddbc2af1 formatting: revert change to %d, %o, %b, %x for now.
We should have a format character in the future to format using our Factor
binary, octal, and hex parser.  Maybe using the "alternate form" format
character like Python does? And if we do that, maybe print the 0b, 0o, 0x
prefixes? TBD.
2017-06-10 13:33:01 -07:00
Jon Harper 1dceb069ad formatting: fix bug when using %e and the number rounds up in magnitude
99/10 0 format-scientific-simple was outputting 1.0e0 because
the mantissa was rounded up, so it had one extra character, and
the exponent was wrong.
2017-06-08 11:23:38 -07:00
Jon Harper 4df21818f5 formatting: change %.0f and %.0e to remove the radix character. It's more standard. 2017-06-08 11:23:38 -07:00
Jon Harper 756184607b formatting: make these tests actually test the expected code path 2017-06-08 11:23:38 -07:00
Jon Harper 552791d1cf formatting: don't force the presence of ".0" for %f and %e when precision is 0
It's misleading because you can think you have more precision than you really
do when looking at the output. So instead of "1.0", we can format it as "1" or
"1.".  And instead of "1.0e+00" we can format "1e+00" or "1.e+00".  In C,
printf does not print the radix character, it's prettier. But since the factor
parser accepts both styles, and keeping the radix character gives a stronger sense
that the number is approximate, I prefer to keep the radix character..
2017-06-08 11:23:38 -07:00
Jon Harper 6061da92be formatting, allow uppercase exponent for bin floats in base 2 and 8 2017-06-08 11:23:37 -07:00
Jon Harper ccbb8116fc formatting, make %d, %o, %b work for ratios and floats 2017-06-08 11:23:37 -07:00
Jon Harper 438e22fceb formatting, fix %f and %e for ratios and integers 2017-06-08 11:23:37 -07:00
Jon Harper e1df9df735 formatting: fix missing '+' for %+e with negative exponent 2017-06-08 11:23:37 -07:00
Doug Coleman 43d6f1d3e2 factor: Retrying on the unit tests. Also normalize some syntax with FUNCTION:. 2015-07-02 17:28:17 -07:00
Doug Coleman 59f3b1ea57 Revert "factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool!"
Needs a bit more work.

This reverts commit 7e54cc2824.
2015-07-02 13:47:06 -07:00
Doug Coleman 7e54cc2824 factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool! 2015-07-02 11:36:08 -07:00
Doug Coleman 77c5783270 formatting: Welcome to the sprintf club, MSVC 2015. Fixes #1337. 2015-06-06 05:54:22 -07:00
John Benediktsson 50725002be formatting: support space prefix for numbers. 2015-04-17 17:50:00 -07:00
John Benediktsson 0287355e2a formatting: adding octal and binary format directives. 2014-08-05 09:39:50 -07:00
John Benediktsson f29aac24bb formatting: adding vprintf by request. 2013-05-14 09:23:00 -07:00
Joe Groff 943596575a use radix literals 2011-11-23 19:03:40 -08:00
Slava Pestov f26bf45b4a formatting: fix unit tests on Windows; libc's float formatting produces different output there 2010-04-15 13:49:16 -05:00
Slava Pestov 8f4210436b formatting: use the new format-float word to fix a failing test case 2010-04-13 21:24:35 -07:00
Doug Coleman 3f3d57032b Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places, minor refactoring 2009-08-13 19:21:44 -05:00
John Benediktsson fdd6dd68f2 Adding tests for sequence and assocs formatting. 2009-01-30 14:21:38 -08:00
John Benediktsson b43dce4668 Merge branch 'master' of git://factorcode.org/git/factor 2008-12-18 06:50:42 -08:00
Slava Pestov da38cd36dd Move assoc-heaps, formatting, pack, roman, porter-stemmer, soundex, cords to basis 2008-12-17 20:18:24 -06:00