You need to sign in to do that
Don't have an account?
SFDC-SD
Exponential Operator Issue - I can't believe it
Guys...
Has any body faced this issue?
integer exponent2 = 2^8; system.debug('Exponent ' +exponent2); Output is: 10 (Actual value should be 256) As per Salesforce Manual: Math Operator ^ Raises a number to a power of a specified number.
The definition of ^ is not of exponent in the apex guide. It is mentioned as
"Bitwise exclusive OR operator. Exclusive ORs each bit in x with the corresponding bit in y so that the result bit is set to 1 if exactly one of the bits is set to 1 and the other bit is set to"
For doing exponent, you can use the pow function.
Eg:
All Answers
The definition of ^ is not of exponent in the apex guide. It is mentioned as
"Bitwise exclusive OR operator. Exclusive ORs each bit in x with the corresponding bit in y so that the result bit is set to 1 if exactly one of the bits is set to 1 and the other bit is set to"
For doing exponent, you can use the pow function.
Eg:
I am not sure which document you are referring to...
http://login.salesforce.com/help/doc/en/customize_functions.htm#PowerDef
I was referring to the Apex Developers Guide. The link you have given is for operators when used in Formula; not apex. (I believe you are writing Apex code.)
My mistake... never used this method or operator and was blindly searching for answers all over.
Thanks for the alert and the Answer.