function as.integer added @vjovanov