private void RecalculateFreqencies1()
{
int inputDivider = 0;
int outputDivider = 0;
int fbDivider = 0;
double tempFrequency = 0.f;
double closestFrequency = 0.f;
long targetFrequencyLong = (long)spn_TargetFrequency1.getValue();
double targetFrequency = (double)targetFrequencyLong;
if(targetFrequencyLong == 50000000)
{
tempFrequency = ( (double)_inputFrequency / (double) 20 ) * (double) 800 / (double) 32;
closestFrequency = tempFrequency;
_pllidivEstimate = 20;
_pllodivEstimate1 = 32;
_pllfbEstimate = 800;
_pllodivEstimate2 = 10;
}
int outputspn2 = _pllodivEstimate1/3;
if (outputspn2<1)
outputspn2 = 1;
spnfreq2 = ( (double)_inputFrequency / (double) _pllidivEstimate ) * (double) _pllodivEstimate1 / (double)outputspn2;
spn_TargetFrequency2.setValue(spnfreq2);
}
private void RecalculateFreqencies2()
{
long targetFrequencyLong2 = (long)spn_TargetFrequency2.getValue();
}
What I have tried:
Getting "java.lang.Double cannot be cast to java.lang.Long exception" here
private void RecalculateFreqencies2()
{
long targetFrequencyLong2 = (long)spn_TargetFrequency2.getValue();//exception
}
解决方案
on executing RecalculateFreqencies2() commenting RecalculateFreqencies1(), exception not seen. RecalculateFreqencies1() sets "spn_TargetFrequency2" value. This value is fetched in RecalculateFreqencies2() using
long targetFrequencyLong2 = (long)spn_TargetFrequency2.getValue();
Here i am getting "java.lang.Double cannot be cast to java.lang.Long exception