If you are going to cast a variable, you’re most likely doing what’s known as a downcast. This means that you’re taking the Object and casting it into a more “specific” type of Object. Here’s an example:

    Object aSentenceObject = 'This is just a regular sentence';
    String aSentenceString = (String)aSentenceObject;

also you can use "upcast"

    String aSentenceString = 'This is just another regular sentence';
    Object aSentenceObject = (Object)aSentenceString;


use [Double.valueOf][1] method

    line.put(targetField, Double.valueOf(fieldValue)); 

  [1]: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_double.htm