void DoubleDoubleSummation::addLong(long long x) { // Split 64-bit integers into two doubles, so the sum remains exact. int64_t high = x / (1ll << 32) * (1ll << 32); int64_t low = x - high; dassert(high + low == x && 1.0 * high == high && 1.0 * low == low); addDouble(low); addDouble(high); }
/** Create or adjust "rot" parameter for a component * Assumed that name either equals "rotx", "roty" or "rotz" otherwise this * method will not add/modify "rot" parameter * @param comp :: Component * @param name :: Parameter name * @param deg :: Parameter value in degrees * @param pDescription :: a pointer (may be NULL) to a string, containing * parameter's * description. If provided, the contents of the string is copied to the * parameter's * memory */ void ParameterMap::addRotationParam(const IComponent *comp, const std::string &name, const double deg, const std::string *const pDescription) { Parameter_sptr paramRotX = get(comp, rotx()); Parameter_sptr paramRotY = get(comp, roty()); Parameter_sptr paramRotZ = get(comp, rotz()); double rotX, rotY, rotZ; if (paramRotX) rotX = paramRotX->value<double>(); else rotX = 0.0; if (paramRotY) rotY = paramRotY->value<double>(); else rotY = 0.0; if (paramRotZ) rotZ = paramRotZ->value<double>(); else rotZ = 0.0; // adjust rotation Quat quat; if (name.compare(rotx()) == 0) { addDouble(comp, rotx(), deg); quat = Quat(deg, V3D(1, 0, 0)) * Quat(rotY, V3D(0, 1, 0)) * Quat(rotZ, V3D(0, 0, 1)); } else if (name.compare(roty()) == 0) { addDouble(comp, roty(), deg); quat = Quat(rotX, V3D(1, 0, 0)) * Quat(deg, V3D(0, 1, 0)) * Quat(rotZ, V3D(0, 0, 1)); } else if (name.compare(rotz()) == 0) { addDouble(comp, rotz(), deg); quat = Quat(rotX, V3D(1, 0, 0)) * Quat(rotY, V3D(0, 1, 0)) * Quat(deg, V3D(0, 0, 1)); } else { g_log.warning() << "addRotationParam() called with unrecognized coordinate symbol: " << name; return; } // clear the position cache clearPositionSensitiveCaches(); // finally add or update "pos" parameter addQuat(comp, rot(), quat, pDescription); }
int main(void) { int resInt = addInt(20,30); double resDouble = addDouble(3.14,2.5); printf("resInt = %d,resDouble = %lf\n",resInt,resDouble); return 0; }
void GLEPcode::addDoubleExpression(double val) { addInt(PCODE_EXPR); int savelen = size(); addInt(0); addDouble(val); setInt(savelen, size() - savelen - 1); }
// // MetaTable::setDouble // // If the metatable already contains a metadouble of the given name, it will // be edited to have the provided value. Otherwise, a new metadouble will be // added to the table with that value. // void MetaTable::setDouble(const char *key, double newValue) { MetaObject *obj; if(!(obj = getObjectKeyAndType(key, RTTI(MetaDouble)))) addDouble(key, newValue); else static_cast<MetaDouble *>(obj)->value = newValue; }
// // MetaTable::setDouble // // If the metatable already contains a metadouble of the given name, it will // be edited to have the provided value. Otherwise, a new metadouble will be // added to the table with that value. // void MetaTable::setDouble(const char *key, double newValue) { MetaDouble *obj; if(!(obj = getObjectKeyAndTypeEx<MetaDouble>(key))) addDouble(key, newValue); else obj->value = newValue; }
int main(){ std::cout << addInt( 3, 5 ) << std::endl; std::cout << addDouble( 3.0, 5.0 ) << std::endl; std::cout << add( 3, 5 ) << std::endl; std::cout << add( 3.0, 5.0 ) << std::endl; std::cout << add( std::string( "3" ), std::string( "5" ) ) << std::endl; return 0; };
char * MessageBuilder::buildDoubleMessage( char const * topicName, double value ) const { aJsonObject * root = aJson.createArray(); add( root, "event" ); add( root, guestName ); add( root, topicName ); addDouble( root, value ); char * string = aJson.print(root); aJson.deleteItem(root); return string; }
CSODistance::CSODistance() : BaseOp(0, 0) { ML_TRACE_IN("CSODistance::CSODistance(int numInImages, int numOutImages) : BaseOp(numInImages, numOutImages)"); handleNotificationOff(); _csoList0 = NULL; _csoList1 = NULL; _tableHeader = "Id1,Id2,min,max,mean,stdDev"; FieldContainer* fieldC = getFieldContainer(); ML_CHECK(fieldC); (_input0CSOFld = fieldC->addBase("inCSOList"))->setBaseValue(NULL); (_input1CSOFld = fieldC->addBase("inCSOList1"))->setBaseValue(NULL); ////////////////////////////////////////////////////////////////////////// char* distanceModes[LASTMODE]; distanceModes[ FIRST2 ] = "First 2 CSOs"; distanceModes[ INPLANE ] = "Match in plane"; distanceModes[ INDEX ] = "Match index"; _modeFld = fieldC->addEnum("mode",distanceModes,LASTMODE); _modeFld->setEnumValue( FIRST2 ); ////////////////////////////////////////////////////////////////////////// (_minimumDistanceFld = fieldC->addFloat("minimumDistance"))->setFloatValue(0); (_minimumDistancePoint1Fld = fieldC->addVec3f("minimumDistancePoint1"))->setVec3fValue(vec3(0.0,0.0,0.0)); (_minimumDistancePoint2Fld = fieldC->addVec3f("minimumDistancePoint2"))->setVec3fValue(vec3(0.0,0.0,0.0)); _distancesFld = addString("distances",_tableHeader ); _AverageMinimumDistanceFld = addDouble("averageMinimumDistance", 0.0 ); _AverageMeanDistanceFld = addDouble("averageMeanDistance", 0.0 ); _AverageMaxDistanceFld = addDouble("averageMaximumDistance", 0.0 ); ////////////////////////////////////////////////////////////////////////// _tolleranceFld = addDouble("tollerance", 0.0001 ); ////////////////////////////////////////////////////////////////////////// _applyFld = fieldC->addNotify("apply"); (_autoApplyFld = fieldC->addBool("autoApply"))->setBoolValue(true); _statusFld = fieldC->addString("status"); _statusFld->setStringValue("Ready"); ////////////////////////////////////////////////////////////////////////// (_listenToRepaintNotificationsFld = fieldC->addBool("listenToRepaintNotifications")) ->setBoolValue(false); (_listenToFinishingNotificationsFld = fieldC->addBool("listenToFinishingNotifications")) ->setBoolValue(true); (_listenToSelectionChangedNotificationsFld = fieldC->addBool("listenToSelectionChangedNotifications")) ->setBoolValue(false); char* statisticsNames[LASTSTATISTIC]; statisticsNames[ MIN ] = "Minimum"; statisticsNames[ MAX ] = "Maximum"; statisticsNames[ MEAN ] = "Mean"; statisticsNames[ STDEV ] = "StDev"; _curveStatistic = addEnum("curveStatistic",statisticsNames,LASTSTATISTIC ); _isInNotificationCB = false; ML_CHECK_NEW(_outputXMarkerList,XMarkerList()); (_outputXMarkerListFld = getFieldContainer()->addBase("outputXMarkerList"))->setBaseValue(NULL); _outputCurveList = new CurveList; (_outputCurveListFld = getFieldContainer()->addBase("outputCurveList"))->setBaseValue( _outputCurveList ); handleNotificationOn(); }
void JIT::compileBinaryArithOpSlowCase(OpcodeID opcodeID, Vector<SlowCaseEntry>::iterator& iter, unsigned result, unsigned op1, unsigned op2, OperandTypes types, bool op1HasImmediateIntFastCase, bool op2HasImmediateIntFastCase) { // We assume that subtracting TagTypeNumber is equivalent to adding DoubleEncodeOffset. COMPILE_ASSERT(((JSImmediate::TagTypeNumber + JSImmediate::DoubleEncodeOffset) == 0), TagTypeNumber_PLUS_DoubleEncodeOffset_EQUALS_0); Jump notImm1; Jump notImm2; if (op1HasImmediateIntFastCase) { notImm2 = getSlowCase(iter); } else if (op2HasImmediateIntFastCase) { notImm1 = getSlowCase(iter); } else { notImm1 = getSlowCase(iter); notImm2 = getSlowCase(iter); } linkSlowCase(iter); // Integer overflow case - we could handle this in JIT code, but this is likely rare. if (opcodeID == op_mul && !op1HasImmediateIntFastCase && !op2HasImmediateIntFastCase) // op_mul has an extra slow case to handle 0 * negative number. linkSlowCase(iter); emitGetVirtualRegister(op1, regT0); Label stubFunctionCall(this); JITStubCall stubCall(this, opcodeID == op_add ? cti_op_add : opcodeID == op_sub ? cti_op_sub : cti_op_mul); if (op1HasImmediateIntFastCase || op2HasImmediateIntFastCase) { emitGetVirtualRegister(op1, regT0); emitGetVirtualRegister(op2, regT1); } stubCall.addArgument(regT0); stubCall.addArgument(regT1); stubCall.call(result); Jump end = jump(); if (op1HasImmediateIntFastCase) { notImm2.link(this); if (!types.second().definitelyIsNumber()) emitJumpIfNotImmediateNumber(regT0).linkTo(stubFunctionCall, this); emitGetVirtualRegister(op1, regT1); convertInt32ToDouble(regT1, fpRegT1); addPtr(tagTypeNumberRegister, regT0); movePtrToDouble(regT0, fpRegT2); } else if (op2HasImmediateIntFastCase) { notImm1.link(this); if (!types.first().definitelyIsNumber()) emitJumpIfNotImmediateNumber(regT0).linkTo(stubFunctionCall, this); emitGetVirtualRegister(op2, regT1); convertInt32ToDouble(regT1, fpRegT1); addPtr(tagTypeNumberRegister, regT0); movePtrToDouble(regT0, fpRegT2); } else { // if we get here, eax is not an int32, edx not yet checked. notImm1.link(this); if (!types.first().definitelyIsNumber()) emitJumpIfNotImmediateNumber(regT0).linkTo(stubFunctionCall, this); if (!types.second().definitelyIsNumber()) emitJumpIfNotImmediateNumber(regT1).linkTo(stubFunctionCall, this); addPtr(tagTypeNumberRegister, regT0); movePtrToDouble(regT0, fpRegT1); Jump op2isDouble = emitJumpIfNotImmediateInteger(regT1); convertInt32ToDouble(regT1, fpRegT2); Jump op2wasInteger = jump(); // if we get here, eax IS an int32, edx is not. notImm2.link(this); if (!types.second().definitelyIsNumber()) emitJumpIfNotImmediateNumber(regT1).linkTo(stubFunctionCall, this); convertInt32ToDouble(regT0, fpRegT1); op2isDouble.link(this); addPtr(tagTypeNumberRegister, regT1); movePtrToDouble(regT1, fpRegT2); op2wasInteger.link(this); } if (opcodeID == op_add) addDouble(fpRegT2, fpRegT1); else if (opcodeID == op_sub) subDouble(fpRegT2, fpRegT1); else if (opcodeID == op_mul) mulDouble(fpRegT2, fpRegT1); else { ASSERT(opcodeID == op_div); divDouble(fpRegT2, fpRegT1); } moveDoubleToPtr(fpRegT1, regT0); subPtr(tagTypeNumberRegister, regT0); emitPutVirtualRegister(result, regT0); end.link(this); }
/** Create or adjust "rot" parameter for a component * Assumed that name either equals "rotx", "roty" or "rotz" otherwise this * method will not add/modify "rot" parameter * @param comp :: Component * @param name :: Parameter name * @param deg :: Parameter value in degrees */ void ParameterMap::addRotationParam(const IComponent* comp,const std::string& name, const double deg) { Parameter_sptr param = get(comp,"rot"); Quat quat; Parameter_sptr paramRotX = get(comp,"rotx"); Parameter_sptr paramRotY = get(comp,"roty"); Parameter_sptr paramRotZ = get(comp,"rotz"); double rotX, rotY, rotZ; if ( paramRotX ) rotX = paramRotX->value<double>(); else rotX = 0.0; if ( paramRotY ) rotY = paramRotY->value<double>(); else rotY = 0.0; if ( paramRotZ ) rotZ = paramRotZ->value<double>(); else rotZ = 0.0; // adjust rotation if ( name.compare("rotx")==0 ) { if (paramRotX) paramRotX->set(deg); else addDouble(comp, "rotx", deg); quat = Quat(deg,V3D(1,0,0))*Quat(rotY,V3D(0,1,0))*Quat(rotZ,V3D(0,0,1)); } else if ( name.compare("roty")==0 ) { if (paramRotY) paramRotY->set(deg); else addDouble(comp, "roty", deg); quat = Quat(rotX,V3D(1,0,0))*Quat(deg,V3D(0,1,0))*Quat(rotZ,V3D(0,0,1)); } else if ( name.compare("rotz")==0 ) { if (paramRotZ) paramRotZ->set(deg); else addDouble(comp, "rotz", deg); quat = Quat(rotX,V3D(1,0,0))*Quat(rotY,V3D(0,1,0))*Quat(deg,V3D(0,0,1)); } else { g_log.warning() << "addRotationParam() called with unrecognised coordinate symbol: " << name; return; } //clear the position cache clearCache(); // finally add or update "pos" parameter if (param) param->set(quat); else addQuat(comp, "rot", quat); }