It depends what "." is. I assume because you're using functions like xs:integer(.) you're asking about XPath 2.0. If "." is an untyped node, then ". = 2" will atomize the node to give an untypedAtomic value, and will then convert both values to doubles to do the comparison. This will work if the node has the value "2.0" (giving true) or "2.5" (giving false). On the other hand xs:integer(.) = 2 will fail if the value is "2.0" or "2.5", because these can't be converted to integers.
Generally, with schemaless data, untyped nodes will be converted automatically to the required type and you only need to do explicit conversions in special cases, for example if you really do want integer arithmetic rather than double arithmetic.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference