本文整理汇总了C++中ValueToDouble函数的典型用法代码示例。如果您正苦于以下问题:C++ ValueToDouble函数的具体用法?C++ ValueToDouble怎么用?C++ ValueToDouble使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValueToDouble函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValueToDouble
void PrefabWithMesh_Plant::_setRotation( const wstring & attribute, const wstring & value )
{
static rotation_struct rot;
if (attribute == x_rot)
{
rot.x_rot = ValueToDouble(value);
} else if (attribute == y_rot)
{
rot.y_rot = ValueToDouble(value);
} else if (attribute == z_rot)
{
rot.z_rot = ValueToDouble(value);
} else if (attribute == closeNode)
{
if (_prefabWithMesh == NULL)
{
throw("PrefabWithMesh SetRotation: try to use uninitialized prefab");
}
_prefabWithMesh->setRotation(rot);
rot.x_rot = rot.y_rot = rot.z_rot = 0;
} else
{
throw My_Exception("PrefabPlantWithMesh _setRotation: Missing attribute type");
}
}
示例2: AdditionFunction
globle void AdditionFunction(
void *theEnv,
DATA_OBJECT_PTR returnValue)
{
double ftotal = 0.0;
long ltotal = 0L;
intBool useFloatTotal = FALSE;
EXPRESSION *theExpression;
DATA_OBJECT theArgument;
int pos = 1;
/*=================================================*/
/* Loop through each of the arguments adding it to */
/* a running total. If a floating point number is */
/* encountered, then do all subsequent operations */
/* using floating point values. */
/*=================================================*/
theExpression = GetFirstArgument();
while (theExpression != NULL)
{
if (! GetNumericArgument(theEnv,theExpression,"+",&theArgument,useFloatTotal,pos)) theExpression = NULL;
else theExpression = GetNextArgument(theExpression);
if (useFloatTotal)
{ ftotal += ValueToDouble(theArgument.value); }
else
{
if (theArgument.type == INTEGER)
{ ltotal += ValueToLong(theArgument.value); }
else
{
ftotal = (double) ltotal + ValueToDouble(theArgument.value);
useFloatTotal = TRUE;
}
}
pos++;
}
/*======================================================*/
/* If a floating point number was in the argument list, */
/* then return a float, otherwise return an integer. */
/*======================================================*/
if (useFloatTotal)
{
returnValue->type = FLOAT;
returnValue->value = (void *) EnvAddDouble(theEnv,ftotal);
}
else
{
returnValue->type = INTEGER;
returnValue->value = (void *) EnvAddLong(theEnv,ltotal);
}
}
示例3: while
static void *FindDefaultValue(
void *theEnv,
int theType,
CONSTRAINT_RECORD *theConstraints,
void *standardDefault)
{
struct expr *theList;
/*=====================================================*/
/* Look on the the allowed values list to see if there */
/* is a value of the requested type. Return the first */
/* value found of the requested type. */
/*=====================================================*/
theList = theConstraints->restrictionList;
while (theList != NULL)
{
if (theList->type == theType) return(theList->value);
theList = theList->nextArg;
}
/*=============================================================*/
/* If no specific values were available for the default value, */
/* and the type requested is a float or integer, then use the */
/* range attribute to select a default value. */
/*=============================================================*/
if (theType == INTEGER)
{
if (theConstraints->minValue->type == INTEGER)
{ return(theConstraints->minValue->value); }
else if (theConstraints->minValue->type == FLOAT)
{ return(EnvAddLong(theEnv,(long long) ValueToDouble(theConstraints->minValue->value))); }
else if (theConstraints->maxValue->type == INTEGER)
{ return(theConstraints->maxValue->value); }
else if (theConstraints->maxValue->type == FLOAT)
{ return(EnvAddLong(theEnv,(long long) ValueToDouble(theConstraints->maxValue->value))); }
}
else if (theType == FLOAT)
{
if (theConstraints->minValue->type == FLOAT)
{ return(theConstraints->minValue->value); }
else if (theConstraints->minValue->type == INTEGER)
{ return(EnvAddDouble(theEnv,(double) ValueToLong(theConstraints->minValue->value))); }
else if (theConstraints->maxValue->type == FLOAT)
{ return(theConstraints->maxValue->value); }
else if (theConstraints->maxValue->type == INTEGER)
{ return(EnvAddDouble(theEnv,(double) ValueToLong(theConstraints->maxValue->value))); }
}
/*======================================*/
/* Use the standard default value (such */
/* as nil if symbols are allowed). */
/*======================================*/
return(standardDefault);
}
示例4: FloatFunction
globle double FloatFunction(
void *theEnv)
{
DATA_OBJECT valstruct;
/*============================================*/
/* Check for the correct number of arguments. */
/*============================================*/
if (EnvArgCountCheck(theEnv,"float",EXACTLY,1) == -1) return(0.0);
/*================================================================*/
/* Check for the correct type of argument. Note that ArgTypeCheck */
/* will convert integers to floats when a float is requested */
/* (which is the purpose of the float function). */
/*================================================================*/
if (EnvArgTypeCheck(theEnv,"float",1,FLOAT,&valstruct) == FALSE) return(0.0);
/*================================================*/
/* Return the numeric value converted to a float. */
/*================================================*/
return(ValueToDouble(valstruct.value));
}
示例5: get_argument
void get_argument(void* env, int argposition, Values& values) {
DATA_OBJECT arg;
if (EnvArgTypeCheck(env, (char *)"clipsmm get_argument",
argposition, MULTIFIELD, &arg) == 0) return;
values.clear();
int end = EnvGetDOEnd(env, arg);
void *mfp = EnvGetValue(env, arg);
for (int i = EnvGetDOBegin(env, arg); i <= end; ++i) {
switch (GetMFType(mfp, i)) {
case SYMBOL:
case STRING:
case INSTANCE_NAME:
values.push_back(Value(ValueToString(GetMFValue(mfp, i))));
break;
case FLOAT:
values.push_back(Value(ValueToDouble(GetMFValue(mfp, i))));
break;
case INTEGER:
values.push_back(Value(ValueToInteger(GetMFValue(mfp, i))));
break;
default:
continue;
break;
}
}
}
示例6: ValueToDouble
void GLScreenElement::setValue(const char * key,Value value){
if(strcmp(key, "zPosition") == 0){
_zPosition = ValueToDouble(value, 0);
}
else {
GLCanvasElement::setValue(key,value);
}
}
示例7: GetAtomicHashValue
unsigned long GetAtomicHashValue(
unsigned short type,
void *value,
int position)
{
unsigned long tvalue;
union
{
double fv;
void *vv;
unsigned long liv;
} fis;
switch (type)
{
case FLOAT:
fis.liv = 0;
fis.fv = ValueToDouble(value);
tvalue = fis.liv;
break;
case INTEGER:
tvalue = (unsigned long) ValueToLong(value);
break;
case EXTERNAL_ADDRESS:
fis.liv = 0;
fis.vv = ValueToExternalAddress(value);
tvalue = (unsigned long) fis.liv;
break;
case FACT_ADDRESS:
#if OBJECT_SYSTEM
case INSTANCE_ADDRESS:
#endif
fis.liv = 0;
fis.vv = value;
tvalue = (unsigned long) fis.liv;
break;
case STRING:
#if OBJECT_SYSTEM
case INSTANCE_NAME:
#endif
case SYMBOL:
tvalue = ((SYMBOL_HN *) value)->bucket;
break;
default:
tvalue = type;
}
if (position < 0) return(tvalue);
return((unsigned long) (tvalue * (((unsigned long) position) + 29)));
}
示例8: ModFunction
globle void ModFunction(
void *theEnv,
DATA_OBJECT_PTR result)
{
DATA_OBJECT item1, item2;
double fnum1, fnum2;
long long lnum1, lnum2;
if (EnvArgCountCheck(theEnv,"mod",EXACTLY,2) == -1)
{
result->type = INTEGER;
result->value = (void *) EnvAddLong(theEnv,0L);
return;
}
if (EnvArgTypeCheck(theEnv,"mod",1,INTEGER_OR_FLOAT,&item1) == FALSE)
{
result->type = INTEGER;
result->value = (void *) EnvAddLong(theEnv,0L);
return;
}
if (EnvArgTypeCheck(theEnv,"mod",2,INTEGER_OR_FLOAT,&item2) == FALSE)
{
result->type = INTEGER;
result->value = (void *) EnvAddLong(theEnv,0L);
return;
}
if (((item2.type == INTEGER) ? (ValueToLong(item2.value) == 0L) : FALSE) ||
((item2.type == FLOAT) ? ValueToDouble(item2.value) == 0.0 : FALSE))
{
DivideByZeroErrorMessage(theEnv,"mod");
SetEvaluationError(theEnv,TRUE);
result->type = INTEGER;
result->value = (void *) EnvAddLong(theEnv,0L);
return;
}
if ((item1.type == FLOAT) || (item2.type == FLOAT))
{
fnum1 = CoerceToDouble(item1.type,item1.value);
fnum2 = CoerceToDouble(item2.type,item2.value);
result->type = FLOAT;
result->value = (void *) EnvAddDouble(theEnv,fnum1 - (dtrunc(fnum1 / fnum2) * fnum2));
}
else
{
lnum1 = DOToLong(item1);
lnum2 = DOToLong(item2);
result->type = INTEGER;
result->value = (void *) EnvAddLong(theEnv,lnum1 - (lnum1 / lnum2) * lnum2);
}
}
示例9: AbsFunction
globle void AbsFunction(
void *theEnv,
DATA_OBJECT_PTR returnValue)
{
/*============================================*/
/* Check for the correct number of arguments. */
/*============================================*/
if (EnvArgCountCheck(theEnv,"abs",EXACTLY,1) == -1)
{
returnValue->type = INTEGER;
returnValue->value = (void *) EnvAddLong(theEnv,0L);
return;
}
/*======================================*/
/* Check that the argument is a number. */
/*======================================*/
if (EnvArgTypeCheck(theEnv,"abs",1,INTEGER_OR_FLOAT,returnValue) == FALSE)
{
returnValue->type = INTEGER;
returnValue->value = (void *) EnvAddLong(theEnv,0L);
return;
}
/*==========================================*/
/* Return the absolute value of the number. */
/*==========================================*/
if (returnValue->type == INTEGER)
{
if (ValueToLong(returnValue->value) < 0L)
{ returnValue->value = (void *) EnvAddLong(theEnv,- ValueToLong(returnValue->value)); }
}
else if (ValueToDouble(returnValue->value) < 0.0)
{ returnValue->value = (void *) EnvAddDouble(theEnv,- ValueToDouble(returnValue->value)); }
}
示例10: EnvRtnLong
globle long EnvRtnLong(
void *theEnv,
int argumentPosition)
{
int count = 1;
DATA_OBJECT result;
struct expr *argPtr;
/*=====================================================*/
/* Find the appropriate argument in the argument list. */
/*=====================================================*/
for (argPtr = EvaluationData(theEnv)->CurrentExpression->argList;
(argPtr != NULL) && (count < argumentPosition);
argPtr = argPtr->nextArg)
{ count++; }
if (argPtr == NULL)
{
NonexistantError(theEnv,"RtnLong",
ValueToString(ExpressionFunctionCallName(EvaluationData(theEnv)->CurrentExpression)),
argumentPosition);
SetHaltExecution(theEnv,TRUE);
SetEvaluationError(theEnv,TRUE);
return(1L);
}
/*======================================*/
/* Return the value of the nth argument */
/* if it is a float or integer. */
/*======================================*/
EvaluateExpression(theEnv,argPtr,&result);
if (result.type == FLOAT)
{ return((long) ValueToDouble(result.value)); }
else if (result.type == INTEGER)
{ return(ValueToLong(result.value)); }
/*======================================================*/
/* Generate an error if the argument is the wrong type. */
/*======================================================*/
ExpectedTypeError3(theEnv,"RtnLong",
ValueToString(ExpressionFunctionCallName(EvaluationData(theEnv)->CurrentExpression)),
argumentPosition,"number");
SetHaltExecution(theEnv,TRUE);
SetEvaluationError(theEnv,TRUE);
return(1L);
}
示例11: RoundFunction
globle long long RoundFunction(
void *theEnv)
{
DATA_OBJECT result;
if (EnvArgCountCheck(theEnv,"round",EXACTLY,1) == -1)
{ return(0LL); }
if (EnvArgTypeCheck(theEnv,"round",1,INTEGER_OR_FLOAT,&result) == FALSE)
{ return(0LL); }
if (result.type == INTEGER)
{ return(ValueToLong(result.value)); }
else
{ return((long long) ceil(ValueToDouble(result.value) - 0.5)); }
}
示例12: GetAtomicHashValue
unsigned int GetAtomicHashValue(
int type,
void *value,
int position)
{
unsigned int tvalue;
union
{
double fv;
unsigned int liv;
} fis;
switch (type)
{
case FLOAT:
fis.fv = ValueToDouble(value);
tvalue = fis.liv;
break;
case INTEGER:
tvalue = (unsigned int) ValueToLong(value);
break;
case FACT_ADDRESS:
#if OBJECT_SYSTEM
case INSTANCE_ADDRESS:
#endif
case EXTERNAL_ADDRESS:
tvalue = (unsigned int) value;
break;
case STRING:
#if OBJECT_SYSTEM
case INSTANCE_NAME:
#endif
case SYMBOL:
tvalue = ((SYMBOL_HN *) value)->bucket;
break;
default:
tvalue = type;
}
if (position < 0) return(tvalue);
return((unsigned int) (tvalue * (position + 29)));
}
示例13: ItemHashValue
globle int ItemHashValue(
int theType,
void *theValue,
int theRange)
{
switch(theType)
{
case FLOAT:
return(HashFloat(ValueToDouble(theValue),theRange));
case INTEGER:
return(HashInteger(ValueToLong(theValue),theRange));
case SYMBOL:
case STRING:
#if OBJECT_SYSTEM
case INSTANCE_NAME:
#endif
return(HashSymbol(ValueToString(theValue),theRange));
case MULTIFIELD:
return(HashMultifield((struct multifield *) theValue,theRange));
#if DEFTEMPLATE_CONSTRUCT
case FACT_ADDRESS:
return(HashFact((struct fact *) theValue) % theRange);
#endif
case EXTERNAL_ADDRESS:
#if OBJECT_SYSTEM
case INSTANCE_ADDRESS:
#endif
return(((int) theValue) % theRange);
default:
SystemError("UTILITY",1);
return(-1L);
}
return(-1L);
}
示例14: CompareNumbers
globle int CompareNumbers(
void *theEnv,
EXEC_STATUS,
int type1,
void *vptr1,
int type2,
void *vptr2)
{
/*============================================*/
/* Handle the situation in which the values */
/* are exactly equal (same type, same value). */
/*============================================*/
if (vptr1 == vptr2) return(EQUAL);
/*=======================================*/
/* Handle the special cases for positive */
/* and negative infinity. */
/*=======================================*/
if (vptr1 == SymbolData(theEnv,execStatus)->PositiveInfinity) return(GREATER_THAN);
if (vptr1 == SymbolData(theEnv,execStatus)->NegativeInfinity) return(LESS_THAN);
if (vptr2 == SymbolData(theEnv,execStatus)->PositiveInfinity) return(LESS_THAN);
if (vptr2 == SymbolData(theEnv,execStatus)->NegativeInfinity) return(GREATER_THAN);
/*=======================*/
/* Compare two integers. */
/*=======================*/
if ((type1 == INTEGER) && (type2 == INTEGER))
{
if (ValueToLong(vptr1) < ValueToLong(vptr2))
{ return(LESS_THAN); }
else if (ValueToLong(vptr1) > ValueToLong(vptr2))
{ return(GREATER_THAN); }
return(EQUAL);
}
/*=====================*/
/* Compare two floats. */
/*=====================*/
if ((type1 == FLOAT) && (type2 == FLOAT))
{
if (ValueToDouble(vptr1) < ValueToDouble(vptr2))
{ return(LESS_THAN); }
else if (ValueToDouble(vptr1) > ValueToDouble(vptr2))
{ return(GREATER_THAN); }
return(EQUAL);
}
/*================================*/
/* Compare an integer to a float. */
/*================================*/
if ((type1 == INTEGER) && (type2 == FLOAT))
{
if (((double) ValueToLong(vptr1)) < ValueToDouble(vptr2))
{ return(LESS_THAN); }
else if (((double) ValueToLong(vptr1)) > ValueToDouble(vptr2))
{ return(GREATER_THAN); }
return(EQUAL);
}
/*================================*/
/* Compare a float to an integer. */
/*================================*/
if ((type1 == FLOAT) && (type2 == INTEGER))
{
if (ValueToDouble(vptr1) < ((double) ValueToLong(vptr2)))
{ return(LESS_THAN); }
else if (ValueToDouble(vptr1) > ((double) ValueToLong(vptr2)))
{ return(GREATER_THAN); }
return(EQUAL);
}
/*===================================*/
/* One of the arguments was invalid. */
/* Return -1 to indicate an error. */
/*===================================*/
return(-1);
}
示例15: PrintAtom
globle void PrintAtom(
char *logicalName,
int type,
void *value)
{
char buffer[20];
switch (type)
{
case FLOAT:
PrintFloat(logicalName,ValueToDouble(value));
break;
case INTEGER:
PrintLongInteger(logicalName,ValueToLong(value));
break;
case SYMBOL:
PrintRouter(logicalName,ValueToString(value));
break;
case STRING:
if (PreserveEscapedCharacters)
{ PrintRouter(logicalName,StringPrintForm(ValueToString(value))); }
else
{
PrintRouter(logicalName,"\"");
PrintRouter(logicalName,ValueToString(value));
PrintRouter(logicalName,"\"");
}
break;
case EXTERNAL_ADDRESS:
if (AddressesToStrings) PrintRouter(logicalName,"\"");
PrintRouter(logicalName,"<Pointer-");
sprintf(buffer,"%p",value);
PrintRouter(logicalName,buffer);
PrintRouter(logicalName,">");
if (AddressesToStrings) PrintRouter(logicalName,"\"");
break;
#if OBJECT_SYSTEM
case INSTANCE_NAME:
PrintRouter(logicalName,"[");
PrintRouter(logicalName,ValueToString(value));
PrintRouter(logicalName,"]");
break;
#endif
#if FUZZY_DEFTEMPLATES
case FUZZY_VALUE:
PrintFuzzyValue(logicalName,ValueToFuzzyValue(value));
break;
#endif
case RVOID:
break;
default:
if (PrimitivesArray[type] == NULL) break;
if (PrimitivesArray[type]->longPrintFunction == NULL)
{
PrintRouter(logicalName,"<unknown atom type>");
break;
}
(*PrimitivesArray[type]->longPrintFunction)(logicalName,value);
break;
}
}