Hi,
I am occasionally using this simple test:
type = $1 + 0 == $1 ? "numerical" : "not numerical"
I am just wondering: can there be cases where this test will fail ?
Thanks in advance, Hermann
|
|
0
|
|
|
|
Reply
|
Hermann
|
1/20/2009 8:04:39 PM |
|
Hermann Peifer escribi�:
> Hi,
>
> I am occasionally using this simple test:
>
> type = $1 + 0 == $1 ? "numerical" : "not numerical"
>
> I am just wondering: can there be cases where this test will fail ?
>
It depends on how you define "numerical". Values ouside the supported
numerical range are considered "not numerical", even if they follow the
grammar rules for numerical tokens. Example (32 bit platform):
1e308 - numerical
2e308 - not numerical
> Thanks in advance, Hermann
Regards.
--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
|
|
0
|
|
|
|
Reply
|
Manuel
|
1/20/2009 9:36:50 PM
|
|
On Jan 20, 2:04=A0pm, Hermann Peifer <pei...@gmx.eu> wrote:
> Hi,
>
> I am occasionally using this simple test:
>
> type =3D $1 + 0 =3D=3D $1 ? "numerical" : "not numerical"
>
> I am just wondering: can there be cases where this test will fail ?
>
> Thanks in advance, Hermann
Is "1,000" numerical?
Ed.
|
|
0
|
|
|
|
Reply
|
Ed
|
1/20/2009 10:02:11 PM
|
|
Ed Morton wrote:
> On Jan 20, 2:04 pm, Hermann Peifer <pei...@gmx.eu> wrote:
>> Hi,
>>
>> I am occasionally using this simple test:
>>
>> type = $1 + 0 == $1 ? "numerical" : "not numerical"
>>
>> I am just wondering: can there be cases where this test will fail ?
>>
>> Thanks in advance, Hermann
>
> Is "1,000" numerical?
>
> Ed.
Not according to our business rules.
Hermann
|
|
0
|
|
|
|
Reply
|
Hermann
|
1/20/2009 11:12:28 PM
|
|
On Wednesday 21 January 2009 00:12, Hermann Peifer wrote:
> Ed Morton wrote:
>> On Jan 20, 2:04 pm, Hermann Peifer <pei...@gmx.eu> wrote:
>>> Hi,
>>>
>>> I am occasionally using this simple test:
>>>
>>> type = $1 + 0 == $1 ? "numerical" : "not numerical"
>>>
>>> I am just wondering: can there be cases where this test will fail ?
>>>
>>> Thanks in advance, Hermann
>>
>> Is "1,000" numerical?
>>
>> Ed.
>
> Not according to our business rules.
and neither according to awk grammr, AFAICT.
|
|
0
|
|
|
|
Reply
|
pk
|
1/21/2009 9:18:34 AM
|
|
pk wrote:
> On Wednesday 21 January 2009 00:12, Hermann Peifer wrote:
>
>> Ed Morton wrote:
>>> On Jan 20, 2:04 pm, Hermann Peifer <pei...@gmx.eu> wrote:
>>>> Hi,
>>>>
>>>> I am occasionally using this simple test:
>>>>
>>>> type = $1 + 0 == $1 ? "numerical" : "not numerical"
>>>>
>>>> I am just wondering: can there be cases where this test will fail ?
>>>>
>>>> Thanks in advance, Hermann
>>> Is "1,000" numerical?
>>>
>>> Ed.
>> Not according to our business rules.
>
> and neither according to awk grammr, AFAICT.
As far as I am aware: Gawk's grammar rules have changed over time. In the current version 3.1.6, the above test would only result in "numerical" if you would use the new option, --use-lc-numeric, and would be working with ... say: de_DE.UTF-8 locale settings.
See also: http://tinyurl.com/88zhy4
Hermann
|
|
0
|
|
|
|
Reply
|
Hermann
|
1/21/2009 6:08:59 PM
|
|
|
5 Replies
184 Views
(page loaded in 0.057 seconds)
Similiar Articles: IS NUMERIC check for SPACES - comp.lang.cobolHi All, I had a question regarding blanks or SPACES in numeric fields. Would SPACES pass the IS NUMERIC test used for checking if the value is numeric or ... get values from the textbox in perl TK - comp.lang.perl.misc ...Test if value is numerical - comp.lang.awk... IP range - comp.lang.perl.misc ... Test if value is ... find out if it a numeric value. For example, you have an input field ... How do I do a one-tailed ranksum test? - comp.soft-sys.matlab ...How do I do a one-tailed ranksum test? - comp.soft-sys.matlab ... Test if value is numerical - comp.lang.awk However, the (two-tailed) p-value for Fisher's exact test for ... Re: missing numerical values = - infinity? - comp.soft-sys.sas ...The documentation clearly states that "a missing value for a numeric variable is smaller ... but the > ones I do know all generate a binary outcome from an IF test. Check if a variable is a number - comp.lang.tclAnything that is a numerical value). If I use if { [string is alnum "$_var1"] != 1} The strings like " " or " " (all blanks) will pass the test ... Establish When Multiple Fields Are True/False -1/0 Yes/No From A ...Assign value based on value field in query - comp.databases.ms ... ... Test if value is numerical - comp.lang.awk Establish When Multiple Fields Are True/False -1/0 ... delete columns csv file - comp.lang.awkIn awk, any nonzero numeric value or any nonempty string value is true. 0.0e0 is a numeric zero value and the test if($i) results into: false $ cat testdata 0 -0000000 0 ... Checking to see if a value exists - comp.databases.filemaker ...You could also place the value in a global field and test a relationship between that value ... if a variable is a number - comp.lang.tcl Anything that is a numerical value). I have a isNumeric function to check a text field is numeric .. I ...Thanks > > Burnsy Technically, if something is numeric, it shouldn't ... Incidentally, it does not > make much sense to test an ECMAScript Number value for being a ... excelxp tagset and data type in xml - comp.soft-sys.sasods tagsets.ExcelXP path="xxx" file="test.xls"); proc ... the data type definition) but as far as Excel is concerned, the value is still numeric. Numeric Test - JavaScript Tutorials and ScriptsA quick way to test if a field is numeric.: sans serif font parsefloat number 39 whole number numeric value C# String Number, Test Numeric String Values - Dot Net PerlsYou have a string value in your C# program and want to find out if it a numeric value. For example, you have an input field or TextBox, and it contains the string ... 7/15/2012 8:30:27 AM
|