Void AssignDouble ( double that )

From FM Plugin Wikipedia
Jump to: navigation, search

Assign Double

This function allows you to set a 'FixPt' with a 'Double' value.


In some situations, you may find it easier to work with C++'s Double as it provides more calculation options, but then you will want to return the calculated result back to the user.


In the following example, we will assign a Double to a FixPt, and then set it's precision to the default of 16

double      value;
fmx::FixPtAutoPtr    result;

value = 19.2 ;

result->AssignDouble( value );

result->SetPrecision( fmx::FixPt::kDefltFixedPrecision );


In the next example, we will also set the FixPt as out return 'results'

FMX_PROC(fmx::errcode) MyNumber(short /* funcId */, const fmx::ExprEnv& /* environment */, const fmx::DataVect&  /*dataVect */, fmx::Data&  results )
{

 double      valueDouble;
 fmx::FixPtAutoPtr    valueFixPt;

  valueDouble = 19.2 ;                                             // assign our 'double' number

  valueFixPt->AssignDouble( valueDouble );                         // store our 'double' in a 'FixPt'

  valueFixPt->SetPrecision( fmx::FixPt::kDefltFixedPrecision );    // set the precision to 16 (default)

  results.SetAsNumber( *valueFixPt );                              // return as our result to FileMaker

  return 0;   // no error
}