[Bug 19011] New: Wrong validation of length 0.0 - use value.equals(BigDecimal.ZERO) instead of value==BigDecimal.ZERO

https://www.w3.org/Bugs/Public/show_bug.cgi?id=19011

           Summary: Wrong validation of length 0.0 - use
                    value.equals(BigDecimal.ZERO) instead of
                    value==BigDecimal.ZERO
           Product: CSSValidator
           Version: CSS Validator
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Parser
        AssignedTo: dave.null@w3.org
        ReportedBy: hannes+w3cbugs@erven.at
         QAContact: www-validator-cvs@w3.org


Created attachment 1190
  --> https://www.w3.org/Bugs/Public/attachment.cgi?id=1190
Suggested patch

When specifying lengths, CSS allows zero lengths to be specified without a
unit. This works fine for "0", but not for "0.0" .
The specification clearly states that any numbers may contain a decimal point,
so I think that should work.

To reproduce, try this:
* {margin: 0.0}


The reason for this behaviour is what I think is an inappropriate use of the
BigDecimal's "equals" method. As the javadoc states, the method returns only
true when the value and scale for both arguments are identical. This means that
2.0 does not equal 2.00 or for the example above, 0 == BigDecimal.ZERO but 0.0
does not.

I'll attach a patch with all those places corrected that I think need to be
reworked.
There are still some (few) lines where there are still == checks, but where I
was not sure what behaviour was actually intended.

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Tuesday, 25 September 2012 17:57:28 UTC