本文整理汇总了C++中ValueToLong函数的典型用法代码示例。如果您正苦于以下问题:C++ ValueToLong函数的具体用法?C++ ValueToLong怎么用?C++ ValueToLong使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValueToLong函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AdditionFunction
globle void AdditionFunction(
void *theEnv,
DATA_OBJECT_PTR returnValue)
{
double ftotal = 0.0;
long long ltotal = 0LL;
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,(char*)"+",&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);
}
}
示例2: hx_Scene_visit_Func_Int
// DECL: void visit(T* instance, bool (T::*visitMethod)(Node*,C), C cookie);
void hx_Scene_visit_Func_Int(value thisObj, value visitMethod, value cookie)
{
Scene *_thisObj;
long _cookie = ValueToLong(cookie);
ValueToObject(thisObj, _thisObj);
MethodWrapper wrapper;
wrapper.visit(_thisObj, visitMethod, _cookie);
}
示例3: 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)));
}
示例4: MultiplicationFunction
globle void MultiplicationFunction(
void *theEnv,
DATA_OBJECT_PTR returnValue)
{
double ftotal = 1.0;
long ltotal = 1L;
CLIPS_BOOLEAN useFloatTotal = FALSE;
EXPRESSION *theExpression;
DATA_OBJECT theArgument;
int pos = 1;
/*===================================================*/
/* Loop through each of the arguments multiplying it */
/* by a running product. 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);
}
}
示例5: 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);
}
}
示例6: 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)); }
}
示例7: 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);
}
示例8: 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)); }
}
示例9: 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)));
}
示例10: 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);
}
示例11: EnvRtnUnknown
globle struct fact *GetFactAddressOrIndexArgument(
void *theEnv,
const char *theFunction,
int position,
int noFactError)
{
DATA_OBJECT item;
long long factIndex;
struct fact *theFact;
char tempBuffer[20];
EnvRtnUnknown(theEnv,position,&item);
if (GetType(item) == FACT_ADDRESS)
{
if (((struct fact *) GetValue(item))->garbage) return(NULL);
else return (((struct fact *) GetValue(item)));
}
else if (GetType(item) == INTEGER)
{
factIndex = ValueToLong(item.value);
if (factIndex < 0)
{
ExpectedTypeError1(theEnv,theFunction,position,"fact-address or fact-index");
return(NULL);
}
theFact = FindIndexedFact(theEnv,factIndex);
if ((theFact == NULL) && noFactError)
{
gensprintf(tempBuffer,"f-%lld",factIndex);
CantFindItemErrorMessage(theEnv,"fact",tempBuffer);
return(NULL);
}
return(theFact);
}
ExpectedTypeError1(theEnv,theFunction,position,"fact-address or fact-index");
return(NULL);
}
示例12: HashMultifield
globle unsigned long HashMultifield(
struct multifield *theSegment,
unsigned long theRange)
{
unsigned long length, i;
unsigned long tvalue;
unsigned long count;
struct field *fieldPtr;
union
{
double fv;
void *vv;
unsigned long liv;
} fis;
/*================================================*/
/* Initialize variables for computing hash value. */
/*================================================*/
count = 0;
length = theSegment->multifieldLength;
fieldPtr = theSegment->theFields;
/*====================================================*/
/* Loop through each value in the multifield, compute */
/* its hash value, and add it to the running total. */
/*====================================================*/
for (i = 0;
i < length;
i++)
{
switch(fieldPtr[i].type)
{
case MULTIFIELD:
count += HashMultifield((struct multifield *) fieldPtr[i].value,theRange);
break;
case FLOAT:
fis.liv = 0;
fis.fv = ValueToDouble(fieldPtr[i].value);
count += (fis.liv * (i + 29)) +
(unsigned long) ValueToDouble(fieldPtr[i].value);
break;
case INTEGER:
count += (((unsigned long) ValueToLong(fieldPtr[i].value)) * (i + 29)) +
((unsigned long) ValueToLong(fieldPtr[i].value));
break;
case FACT_ADDRESS:
#if OBJECT_SYSTEM
case INSTANCE_ADDRESS:
#endif
fis.liv = 0;
fis.vv = fieldPtr[i].value;
count += (unsigned long) (fis.liv * (i + 29));
break;
case EXTERNAL_ADDRESS:
fis.liv = 0;
fis.vv = ValueToExternalAddress(fieldPtr[i].value);
count += (unsigned long) (fis.liv * (i + 29));
break;
case SYMBOL:
case STRING:
#if OBJECT_SYSTEM
case INSTANCE_NAME:
#endif
tvalue = (unsigned long) HashSymbol(ValueToString(fieldPtr[i].value),theRange);
count += (unsigned long) (tvalue * (i + 29));
break;
}
}
/*========================*/
/* Return the hash value. */
/*========================*/
return(count);
}
示例13: 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;
}
}
示例14: PrintAtom
globle void PrintAtom(
void *theEnv,
const char *logicalName,
int type,
void *value)
{
struct externalAddressHashNode *theAddress;
char buffer[20];
switch (type)
{
case FLOAT:
PrintFloat(theEnv,logicalName,ValueToDouble(value));
break;
case INTEGER:
PrintLongInteger(theEnv,logicalName,ValueToLong(value));
break;
case SYMBOL:
EnvPrintRouter(theEnv,logicalName,ValueToString(value));
break;
case STRING:
if (PrintUtilityData(theEnv)->PreserveEscapedCharacters)
{ EnvPrintRouter(theEnv,logicalName,StringPrintForm(theEnv,ValueToString(value))); }
else
{
EnvPrintRouter(theEnv,logicalName,"\"");
EnvPrintRouter(theEnv,logicalName,ValueToString(value));
EnvPrintRouter(theEnv,logicalName,"\"");
}
break;
case DATA_OBJECT_ARRAY:
if (PrintUtilityData(theEnv)->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
EnvPrintRouter(theEnv,logicalName,"<Pointer-");
gensprintf(buffer,"%p",value);
EnvPrintRouter(theEnv,logicalName,buffer);
EnvPrintRouter(theEnv,logicalName,">");
if (PrintUtilityData(theEnv)->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
break;
case EXTERNAL_ADDRESS:
theAddress = (struct externalAddressHashNode *) value;
if (PrintUtilityData(theEnv)->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
if ((EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type] != NULL) &&
(EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction != NULL))
{ (*EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction)(theEnv,logicalName,value); }
else
{
EnvPrintRouter(theEnv,logicalName,"<Pointer-");
gensprintf(buffer,"%d-",theAddress->type);
EnvPrintRouter(theEnv,logicalName,buffer);
gensprintf(buffer,"%p",ValueToExternalAddress(value));
EnvPrintRouter(theEnv,logicalName,buffer);
EnvPrintRouter(theEnv,logicalName,">");
}
if (PrintUtilityData(theEnv)->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
break;
#if OBJECT_SYSTEM
case INSTANCE_NAME:
EnvPrintRouter(theEnv,logicalName,"[");
EnvPrintRouter(theEnv,logicalName,ValueToString(value));
EnvPrintRouter(theEnv,logicalName,"]");
break;
#endif
case RVOID:
break;
default:
if (EvaluationData(theEnv)->PrimitivesArray[type] == NULL) break;
if (EvaluationData(theEnv)->PrimitivesArray[type]->longPrintFunction == NULL)
{
EnvPrintRouter(theEnv,logicalName,"<unknown atom type>");
break;
}
(*EvaluationData(theEnv)->PrimitivesArray[type]->longPrintFunction)(theEnv,logicalName,value);
break;
}
}
示例15: NumericNotEqualFunction
globle intBool NumericNotEqualFunction(
void *theEnv,
EXEC_STATUS)
{
EXPRESSION *theArgument;
DATA_OBJECT rv1, rv2;
int pos = 1;
/*=========================*/
/* Get the first argument. */
/*=========================*/
theArgument = GetFirstArgument();
if (theArgument == NULL) { return(TRUE); }
if (! GetNumericArgument(theEnv,execStatus,theArgument,"<>",&rv1,FALSE,pos)) return(FALSE);
pos++;
/*=================================================*/
/* Compare each of the subsequent arguments to the */
/* first. If any is equal, then return FALSE. */
/*=================================================*/
for (theArgument = GetNextArgument(theArgument);
theArgument != NULL;
theArgument = GetNextArgument(theArgument), pos++)
{
if (! GetNumericArgument(theEnv,execStatus,theArgument,"<>",&rv2,FALSE,pos)) return(FALSE);
if (rv1.type == INTEGER)
{
if (rv2.type == INTEGER)
{
if (ValueToLong(rv1.value) == ValueToLong(rv2.value))
{ return(FALSE); }
}
else
{
if ((double) ValueToLong(rv1.value) == ValueToDouble(rv2.value))
{ return(FALSE); }
}
}
else
{
if (rv2.type == INTEGER)
{
if (ValueToDouble(rv1.value) == (double) ValueToLong(rv2.value))
{ return(FALSE); }
}
else
{
if (ValueToDouble(rv1.value) == ValueToDouble(rv2.value))
{ return(FALSE); }
}
}
}
/*===================================*/
/* All arguments were unequal to the */
/* first argument. Return TRUE. */
/*===================================*/
return(TRUE);
}