@tore: "Hi!
Not having written many tests myself, I started yesterday looking av some
of the Test modules.  Boring stuff, but an excellent way of keeping your
code clean from those annoying bugs.
However.  In one of the modules, there was a 'is_decimal' function, and it
failed some of my tests.  Not surprisingly, though.  But.  Is there a way
to check if a number is a decimal number even when you declare the value
as a "plain number"?
Example:
  my $nr = 5.00;
  if ( is_decimal($nr) ) {
      print "is_decimal\n";
  }
  sub is_decimal {
      my $nr = shift;
      return ( defined $nr && $nr =~ m,^[+-]?(\d+)?\.\d+$, ) ? 1 : 0;
  }
This always fails, of course, as Perl seems to evaluate _the number_ 5.00
as the number 5 as soon as the variable $nr gets set.  Setting $nr to a
string - ie. '5.00' - works fine.
Is there a way round this "problem"?  No big deal, really, but just out of
curiousity. :-)
Tore Aursand <email_address>"
    @josefmoellers: "<quote>
me
r
 it
ay
e
00
 of
It's not really a "problem", but you give the solution yourself: you're
mixing apples with oranges.
You assign a number to a variable, but do a string test on it. Perl does
a lot of stringification for you (as I have learned only yesterday), but
when it sees "$nr =3D 5.00", it first parses the string "5.00" itself and=
converts it to its internal representation of a number. As this number
has no decimals, stringification of it will return "5", as this is the
simplest representation of 5.00.
[X] I don't know Perl
=2E.. but then ... who does?
 =
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						 T.  Pratchett"
    @tore: "<quote>
As <<url> states:
  "A fraction where the denominator is a power of ten and is therefore
   expressed using a decimal point. For example: 0.37 is the decimal
   equivalent of 37/100."
Hmm.  Don't know; I didn't write the code.  Personally, I would've skipped
it;
  sub is_decimal {
      my $nr = shift;
      return ( defined $nr && $nr =~ /.../ );
  }
That's not the point, though.
Only _one_ who agrees with me!? :-)  Yes, I would like to think of a
decimal number as something express with a decimal point (period), as
mentioned in the dictionary definition.
Optional sign, optional digits, at most one period and one or more digits.
Anyway;  This topic was really a digression.  I just got curious if it was
possible to re-evaluate (or whatever) '$i = 5.00' and state that it _is_ a
decimal number (or whatever you prefer to call it).
Tore Aursand <email_address>"
    @josefmoellers: "<quote>
A "decimal number" is a representation of a number with a base 10 (in
contrast to hexadecimal, octal and binary numbers).
A number with a decimal point, however, is said to "have decimals", it
is a "number with decimals", i.e. there are digits after the decimal
point.
That's the difference, but then ... I'm not a native english speaker.
Josef
 =
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						 T.  Pratchett"
    @purlgurl: "(snipped)
<quote>
Your "5.00" is a whole number expressed with degree of precision.
It is not a true decimal number.
<url>
Usage of @Array = qw (5.00);
will produce:
5.00
  Positive Decimal Number
Usage of @Array = (5.00);
will produce:
5
  Positive Integer Number
You need to treat your input number as a string. A series
of conditional tests are needed to produce a return which
indicates, "Whole Number With 2 Decimal Place Precision."
Purl Gurl
Purl Gurl Net, Delivering Rock N Roll And Fun
At Two Megabits Per Second
<url>"
    @purlgurl: "<quote>
(snipped)
Not to mislead, a "safer" but less precise return would be,
"Integer Number With 2 Decimal Place Precision."
True precision would denote positive versus negative integers.
This person who made this utterance will experience difficulties:
"...refer to the positive integers, non-negative integers, and integers."
Some here will never understand any of this:
"...the integers are a subset of the rational numbers,
    so indeed, a whole number is a decimal number."
Purl Gurl
Learn To Speak, Read And Write Choctaw!
<url>"
{'source': 'USENET', 'other_information': '{"reply_count": 5, "forum_name": "comp.lang.perl.misc.20140729.mbox"}', 'file': 'data/output/usenet-comp.lang.parquet'}