Q:

retrieve a floating point value from mongo db using cpp

Here is my code knowing that test  is floating point in a collection in mongodb database. I don't know what to use to retrieve it. worth to mention I can access name with the following line 
name  = tmpArray[i].embeddedObject().getStringField("name");

string test;    
vector <BSONElement> testArray;
BSONObj bsnobj = cursor->next();
bsnobj.getObjectField("here").elems(tmpArray);
for(int i=0; i<testArray.size(); i++){
    test  = testArray[i].embeddedObject().getObjectField("test").toString();
    cout << test is: <<test << endl ;

}

This results in 
test is: {}

This is how data looks like 
{

"here" : [
    {
        "name" : "x",
        "source" : "xx",
        "test" : 1,

    },
    {
        "name" : "y",
        "source" : "yy",
        "test" : 1,

    }
],

"if" : true

}

A:

There are two issues:
test  = testArray[i].embeddedObject().getObjectField("test").toString();

You were using getObjectField which returns another named BSON object. As you want a double, you'll need to use getField instead. Secondly, to fetch the value of the test field as a double, you can use the function numberDouble. 
So, you could change your code to:
auto test  = testArray[i].embeddedObject().getField("test").numberDouble();

In the sample data you provided, the result would be:
test is: 1.0

