Java and javascript functions for power conversions