debee 0 Newbie Poster

Hi there,

Can someone figure out why I am getting this problem, please. In my algorithm, i have this method that takes in a BigDecimal value and returns a BigDecimal value as shown below:

public BigDecimal sigmoidActivationFunction(BigDecimal sum)
       {
   	  Big_pi test2 = new Big_pi();
         //sum = sum.multiply(new BigDecimal(-1.0));
     	  BigDecimal Set =new BigDecimal("1").add( test2.exp(sum.negate()));
     	  BigDecimal Set1 = new BigDecimal("1").divide(Set,20,RoundingMode.HALF_UP);

   	  return Set1;
     } public BigDecimal sigmoidActivationFunction(BigDecimal sum)
       {
   	  Big_pi test2 = new Big_pi();
         //sum = sum.multiply(new BigDecimal(-1.0));
     	  BigDecimal Set =new BigDecimal("1").add( test2.exp(sum.negate()));
     	  BigDecimal Set1 = new BigDecimal("1").divide(Set,20,RoundingMode.HALF_UP);

   	  return Set1;
     }

In the first iteration of the algorithm, which takes in the value -0.0819636129724986, it returns the right value as 0.47952056060395526686but in the second iteration of the algorithm where the value
-211.8773034144850569680396861906789008904799141085891169268865695256499715247296 is produced by the program and passed into the method, it returned the value 0E-20 which is wrong. Could you tell me why, please? or is it because this valued was not rounded to a scale?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.