summaryrefslogtreecommitdiff
path: root/numeric.c
Commit message (Collapse)AuthorAgeFilesLines
* perlapi: Include general informationKarl Williamson2014-06-051-2/+2
| | | | | | | | | | | Unlike other pod handling routines, autodoc requires the line following an =head1 to be non-empty for its text to be included in the paragraph started by the heading. If you fail to do this, silently the text will be omitted from perlapi. I went through the source code, and where it was apparent that the text was supposed to be in perlapi, deleted the empty line so it would be, with some revisions to make more sense. I added =cuts where I thought it best for the text to not be included.
* Add parameters to "use locale"Karl Williamson2014-06-051-2/+2
| | | | | | | This commit allows one to specify to enable locale-awareness for only a specified subset of the locale categories. Thus you could make a section of code LC_MESSAGES aware, with no locale-awareness for the other categories.
* numeric.c: Remove unnecessary testKarl Williamson2014-06-051-1/+1
| | | | | The second test won't be true unless the first one is (but not vice versa), so no need to test the first.
* numeric.c: White-space onlyKarl Williamson2014-06-051-7/+7
| | | | | The previous commit added a block around this code, so indent correspondingly.
* Make sure locale set right for radix parsingKarl Williamson2014-06-051-1/+6
| | | | | I haven't found a test case this fails for in v5.20, but I'm sure there is one. But two commits from now would fail if this wasn't done.
* Unify the "fall-through" lint annotation.Jarkko Hietaniemi2014-05-291-2/+2
| | | | | | | Used by linters (static checkers), and also good for human readers. Even though "FALL THROUGH" seems to be the most common, e.g BSD lint manual only knows "FALLTHROUGH" (or "FALLTHRU").
* numeric.c: White-space onlyKarl Williamson2014-01-041-20/+21
| | | | | Indent and reflow to 79 columns as a result of the previous commit's adding a block around this code.
* Use new macros to make sure LC_NUMERIC is correctly setKarl Williamson2014-01-041-0/+4
| | | | | | | | | | | This uses the macros added in the previous commit to make sure the current LC_NUMERIC locale is correct during the operation being done; restoring it to its prior condition afterwards. Outside of 'use locale' the locale should be C; inside it should be the underlying default locale. The macros handle the whole thing. In most of the places here, the code was trying to do what the macros do more elegantly, but there are some additional places where we set the locale correctly around an operation that is affected by it.
* numeric.c: Use macros instead of strchr()Karl Williamson2014-01-011-20/+15
| | | | | | | | This replaces uses of strchr() (and hence its loop) with a simple array lookup, mask, and test. This causes an extra test to be needed later in the hex decoding case to get the hex value, instead of a subtract previously. However these two tests are fewer than the average number in strchr().
* perlapi: Consistent spaces after dotsFather Chrysostomos2013-12-291-8/+8
| | | | plus some typo fixes. I probably changed some things in perlintern, too.
* [perl #120426] atof() small value rounding errorsDavid Mitchell2013-12-251-0/+11
| | | | | | | | | | | | | | | | | | | | | | | For something like 0.153e-305, which is small, but not quite the smallest number (which is around 2.2e-308), adding extra digits to the fractional part could cause unnecessary rounding to zero. From the bug report: $ echo 0.1530e-305 | perl -e '$v = <STDIN>; print "v=", $v + 0, "\n";' v=0 $ echo 0.153e-305 | perl -e '$v = <STDIN>; print "v=", $v + 0, "\n";' v=1.53e-306 This was because 0.1234e-305 is calculated as 1234 / (10^309) and 10^309 becomes infinity. In these edge cases, repeatedly decrement the exponent and divide the mantissa by 10 until the exponent becomes in range; in this case we instead calculate 123 / (10^308)
* perlapi: Refer to correct formal parameter nameKarl Williamson2013-11-251-1/+1
|
* Revert "make perl core quiet under -Wfloat-equal"David Mitchell2013-11-161-2/+2
| | | | | | | | | | | A suggested way of avoiding the the warning on nv1 != nv2 by replacing it with (nv1 < nv2 || nv1 > nv2), has too many issues with NaN. [perl #120538]. I haven't found any other way of selectively disabling the warning, so for now I'm just reverting the whole commit. This reverts commit c279c4550ce59702722d0921739b1a1b92701b0d.
* numeric.c: White-space onlyKarl Williamson2013-11-091-1/+1
| | | | Properly indent the branch of an 'if'.
* make perl core quiet under -Wfloat-equalDavid Mitchell2013-11-091-2/+2
| | | | | | | | | | | | | | | | | | | | The gcc option -Wfloat-equal warns when two floating-point numbers are directly compared for equality or inequality, the idea being that this is usually a logic error, and that you should be checking that the values are instead very near to each other. perl on the other hand has lots of reasons to do a direct comparison. Add two macros, NV_eq_nowarn(a,b) and NV_eq_nowarn(a,b) that do the same as (a == b) and (a != b), but without the warnings. They achieve this by instead doing (a < b) || ( a > b). Under gcc at least, this is optimised into the same code as the direct comparison. The are three places that I've left untouched, because they are handling NaNs, and that gets a bit tricky. In particular (nv != nv) is a test for a NaN, and replacing it with (< || >) creates signalling NaNs (whereas == and != create quiet NaNs)
* numeric.c: nit in commentKarl Williamson2013-10-161-1/+1
|
* Proper IEEE overflow semantics for VMS.Craig A. Berry2012-12-231-1/+1
| | | | | | | | | | | Way back in 67597c89125e7e14 we misspelled _IEEE_FP as __IEEE_FP, with a spurious leading underscore. Which I then copied and pasted into pp_pack.c in baf3cf9c09c529. This means that on Alpha and Itanium systems with the default selection of IEEE floating point, we've actually (for the last decade!) been using a workaround intended for VAX or Alpha and Itanium builds that have explicitly selected VAX-compatible floating point formats. Oh well.
* add comment about the atof change [perl #109318]Jesse Luehrs2012-06-261-0/+6
|
* fix c++ compilationJesse Luehrs2012-06-261-1/+1
|
* use a less broken test for locale radix in atof [perl #109318]Jesse Luehrs2012-06-261-10/+15
|
* numeric.c: Fix typo, clarify commentKarl Williamson2012-06-171-2/+2
|
* update the editor hints for spaces, not tabsRicardo Signes2012-05-291-2/+2
| | | | | This updates the editor hints in our files for Emacs and vim to request that tabs be inserted as spaces.
* Add :not_characters parameter to 'use locale'Karl Williamson2012-01-211-2/+2
| | | | | This adds the parameter handling, tests, and documentation for this new feature which allows locale and Unicode to play well with each other.
* diag_listed_as galoreFather Chrysostomos2011-12-281-0/+3
| | | | | In two instances, I actually modified to code to avoid %s for a constant string, as it should be faster that way.
* Add flag to num groks to silence non-portable warningsKarl Williamson2011-07-031-3/+18
| | | | | | | Unicode inversion lists commonly will contain UV_MAX, which may trigger these warnings. Add a flag to suppress them to the numeric grok functions, which can be set by the code that is dealing with these lists
* [perl #32380] numeric.c assumes that NV_DIG+2 will be enough digitsEd Allen Smith2010-10-031-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for all precision possible in NV numeric.c, in the Perl_my_atof2 function, makes the following assumption: /* There is no point in processing more significant digits * than the NV can hold. Note that NV_DIG is a lower-bound value, * while we need an upper-bound value. We add 2 to account for this; * since it will have been conservative on both the first and last digit. * For example a 32-bit mantissa with an exponent of 4 would have * exact values in the set * 4 * 8 * .. * 17179869172 * 17179869176 * 17179869180 * * where for the purposes of calculating NV_DIG we would have to discount * both the first and last digit, since neither can hold all values from * 0..9; but for calculating the value we must examine those two digits. */ #define MAX_SIG_DIGITS (NV_DIG+2) Digits beyond MAX_SIG_DIGITS are ignored. In some systems and/or modes (e.g., with/without using long doubles), this is not the case. One example is IRIX when using long doubles, which are not fully IEEE compliant; with it, while NV_DIG (the _minimum_ number of digits usable) is 31 for long doubles used as NVs, long doubles can have up to 34 digits of accuracy. (As well as IRIX with long doubles, other machines using a mode in which NV is not IEEE compliant (e.g., as found by the following from numeric.c: #ifdef ((defined(VMS) && !defined(__IEEE_FP)) || defined(_UNICOS)) (although UNICOS does not by default use Perl's atof in any event) or as noted in the hints files for DEC OSF with the old MIPS CC) may benefit from a change to this.) I will attach a test program, example set of problematic outputs, and experimental patch so others can explore this on their systems. (With the patch and a -Accflags='-DMAX_SIG_DIG_PLUS=3' (or -Accflags='-DMAX_SIG_DIG_PLUS=4'), the test program was successful. Different values of MAX_SIG_DIG_PLUS may need to be experimented with, especially with different other Configure/compiler flags (long doubles yes/no, optimization affecting floating point, etcetera); 3 was the maximum that did any good on IRIX with long doubles, but others may differ.) I have done some local testing (as in the normal testsuite) of the patch and different -DMAX_SIG_DIG_PLUS values, and will be doing more; it is possible that it would be best to build in the test program into, say, numconvert.t. Patching hints/irix_6.sh to use -DMAX_SIG_DIG_PLUS=3 if long doubles are in use, or a define of MAX_SIG_DIG_PLUS to 3 if defined(IRIX) and long doubles are in use, is also advisable; I have not included either in my patch because I was unsure which was recommended practice.
* Correct pod in numeric.cKarl Williamson2010-07-271-1/+1
|
* Code for allowing uppercase X/B in hexadecimal/binary numbers (#76296).Bo Lindbergh2010-07-061-4/+4
| | | | Signed-off-by: David Golden <dagolden@cpan.org>
* use cBOOL for bool castsDavid Mitchell2010-04-151-3/+3
| | | | | | | | | | | | | bool b = (bool)some_int doesn't necessarily do what you think. In some builds, bool is defined as char, and that cast's behaviour is thus undefined. So this line in mg.c: const bool was_temp = (bool)SvTEMP(sv); was actually setting was_temp to false even when the SVs_TEMP flag was set. Fix this by replacing all the (bool) casts with a new cBOOL() cast macro that (hopefully) does the right thing.
* Add Perl_ck_warner_d(), which combines Perl_ckwarn_d() and Perl_warner().Nicholas Clark2009-10-121-9/+6
| | | | | Replace ckWARN_d{,2,3,4}() && Perl_warner() with it, which trades reduced code size for 1 more function call if warnings are not enabled.
* Add Perl_ck_warner(), which combines Perl_ckwarn() and Perl_warner().Nicholas Clark2009-10-121-17/+14
| | | | | | | Replace ckWARN{,2,3,4}() && Perl_warner() with it, which trades reduced code size (about 0.2%), for 1 more function call if warnings are not enabled. However, if we're now in the L1 or L2 cache when we weren't previously, that's still going to be a speed win.
* PATCH: Large omnibus patch to clean up the JRRT quotesTom Christiansen2008-11-021-2/+4
| | | | | | Message-ID: <25940.1225611819@chthon> Date: Sun, 02 Nov 2008 01:43:39 -0600 p4raw-id: //depot/perl@34698
* Update copyright years.Nicholas Clark2008-10-251-1/+1
| | | p4raw-id: //depot/perl@34585
* assert() that every NN argument is not NULL. Otherwise we have theNicholas Clark2008-02-121-5/+31
| | | | | | | | | | | | ability to create landmines that will explode under someone in the future when they upgrade their compiler to one with better optimisation. We've already done this at least twice. (Yes, some of the assertions are after code that would already have SEGVd because it already deferences a pointer, but they are put in to make it easier to automate checking that each and every case is covered.) Add a tool, checkARGS_ASSERT.pl, to check that every case is covered. p4raw-id: //depot/perl@33291
* Fix up copyright years for files modified in 2007.Nicholas Clark2007-11-071-2/+2
| | | p4raw-id: //depot/perl@32237
* The revenge of the constsAndy Lester2007-05-031-3/+2
| | | | | Message-ID: <20070503054554.GA30975@petdance.com> p4raw-id: //depot/perl@31123
* signbit detection (was [perl #39875] -0.0 loses signedness upon numeric ↵Andy Dougherty2007-02-101-0/+32
| | | | | | | comparison) Message-ID: <Pine.LNX.4.62.0702091121400.10202@fractal.phys.lafayette.edu> p4raw-id: //depot/perl@30192
* unused context warningsAndy Lester2006-02-241-0/+4
| | | | | Message-ID: <20060221062711.GA16160@petdance.com> p4raw-id: //depot/perl@27300
* Update copyright years (including some years where we made changes butNicholas Clark2006-01-081-1/+1
| | | | | did not update) p4raw-id: //depot/perl@26732
* sprinkle dVARJarkko Hietaniemi2006-01-061-0/+2
| | | | | Message-ID: <43BE7C4D.1010302@gmail.com> p4raw-id: //depot/perl@26675
* Etta James presents: More constingAndy Lester2005-10-311-3/+3
| | | | | Message-ID: <20051031054413.GA10767@petdance.com> p4raw-id: //depot/perl@25915
* Add a new file, mathoms.c, to hold old code kept around for binarySteve Peters2005-10-281-16/+0
| | | | | | | compatability with previous versions of Perl. Change also includes various Makefile changes to compile the new file and link it into libperl. p4raw-id: //depot/perl@25866
* Make some casts explicit to keep VC++ 7 happySteve Hay2005-10-171-3/+3
| | | | | | | | Specifically, this silences the warnings from the following smoke: http://www.nntp.perl.org/group/perl.daily-build.reports/32258 (Hmm. Looks like you need to decode the base64 yourself before you can read that.) p4raw-id: //depot/perl@25779
* 5.9.x (and 5.8.x): Symbian updateJarkko Hietaniemi2005-08-181-1/+1
| | | | | Message-ID: <B356D8F434D20B40A8CEDAEC305A1F24E7A41B@esebe105.NOE.Nokia.com> p4raw-id: //depot/perl@25304
* Re: [perl #36654] Inconsistent treatment of NaNYitzchak Scott-Thoennes2005-08-171-0/+15
| | | | | | | | | | | Date: Aug 7, 2005 8:03 PM Message-ID: <20050807180308.GA2112@efn.org> Subject: Re: [perl #36654] Inconsistent treatment of NaN From: Yitzchak Scott-Thoennes <sthoenna@efn.org> Date: Wed, 10 Aug 2005 22:53:51 -0700 Message-ID: <20050811055351.GA2296@efn.org> p4raw-id: //depot/perl@25299
* Random cleanups #47Andy Lester2005-06-071-1/+1
| | | | | Message-ID: <20050606151107.GC7022@petdance.com> p4raw-id: //depot/perl@24735
* consting-eleventy.patch: More consts, plus actual bug fixAndy Lester2005-05-161-2/+1
| | | | | Message-ID: <20050516151353.GA25387@petdance.com> p4raw-id: //depot/perl@24489
* Include vim/emacs modelines in generated files to open themRafael Garcia-Suarez2005-05-111-2/+2
| | | | | | in read-only mode. Make vi modelines compatible with non-vim vi versions. p4raw-id: //depot/perl@24445
* Add editor boilerplates to all C filesRafael Garcia-Suarez2005-05-101-0/+10
| | | | | (except the generated ones) p4raw-id: //depot/perl@24440
* Symbian port of PerlJarkko Hietaniemi2005-04-211-0/+1
| | | | | Message-ID: <B356D8F434D20B40A8CEDAEC305A1F2453D653@esebe105.NOE.Nokia.com> p4raw-id: //depot/perl@24271