function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shan876shan876 

Illegal assignment from Double to Integer?????

Hi Happy Holidays...
I have a number(5,2) field and when I try to update it through apex code I get the following statement

Error: Compile Error: Illegal assignment from Double to Integer

I have it written like so:
Integer intg=pos.Days_Pend;

intg='1.0';

Does anyone know how to fix this??
nwingnwing
I am using the 'intvalue' as shown below to assign a double to an integer variable...
 
Code:
Double mthsD = newSiteLeaseCumCost[i].Lease_Term_In_Months__c;
Double escmthD = newSiteLeaseCumCost[i].Escalation_Month__c;
   
Integer mths = mthsD.intValue();
Integer escmth = escmthD.intValue();

 
Is that what you are interested in?
kevinbnpowerkevinbnpower
Number values, regardless of what they are through the interface, are always saved as doubles on the backend.  So even if you create a number value with 0 precision, its still represented as a double variable within that object's properties.
ram tungalaram tungala
i have written this in apex class 


public void cube()
{
    res2=math.pow(n,3);
    system.debug('the value of cube is----'+res2);
    }
}

but the error :Illegal assignment from Double to Integer