demerphq is quite correct. The only thing that is "special" about "0E0" is that it is documented in the Perl DBI. I have classic EE training so working with exponents is easy for me. However, I like the 0E0 idea and find it preferable to 0E5 or say "00" because a simple typo "0" gets us into another special case which might be hard to find in the code. This 0E0 values allows the DBI to express 2 ideas in one return value: 1) did it work or not? and 2)how many results were obtained.
I think we've "nailed this one". Here is summary of these special things:
- string "0", this would normally be "true" in a string context, because all non-null strings are
"true". However this is a special case
where it evaluates to "false" in a string context. So the special case code allows a more
intuitive behavior although technically an exception to the standard rules.
Of course this is numeric zero in
a numeric context as would be expected.
- string "0 but true", this is a special case where you can do math on this, e.g.. $val +=0; and no warning
will occur even with warnings enabled. Normally there would be a warning of $val is non-numeric at line x...". This of course
is "true" in a string context (all non-null are normally "true") and zero in a numeric context, just like it says.
This is not seen as often
as the next string ("0E0") which accomplishes the same thing.
- string "0E0", This could have been any string that evaluates to zero in a numeric context,
e.g. "00" or "0E5", However 0E0 is the documented return value in the DB for the
"0 but true" value. Since this is a valid number in a string context, no special code need
execute like in case (2).
Note: When I work with something that can return (2) or (3) and I make use of that, I add a comment to explain what is going on. Even if you know what is going on when you write the code, 3 years later, that might be "fuzzy".
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.