Exemple #1
0
 bool isNumber(const char *s) {
     int l = 0;
     while(*(s + l) == ' ')
     {
         l++;
     }
     int r = strlen(s) - 1;
     while(*(s + r) == ' ')
     {
         r--;
     }
     int il = l;
     int ir;
     int dl;
     int dr;
     for(int i = l; i <= r; i++)
     {
         if(*(s + i) == 'e')
         {
             ir = i - 1;
             dl = i + 1;
             dr = r;
             return isFloat(s, il, ir) && isInteger(s, dl, dr);
         }
     }
     return isFloat(s, il, r);
 }
/***************************************************************************
 * emit shiftRightUnsigned Operation
  ***************************************************************************/	
CCgNodeData* CCilCodeGen::emitShiftRightUnsignedOperator( CCgNodeData* nodetree )
{
	assert( nodetree != NULL );
	assert( nodetree->NodeType == CG_NODE_FORMULANODE );

	CCgNodeData* ptr = nodetree->lhsNode;
	if( isValue( ptr ) && isValue( nodetree->rhsNode ) )
	{
		//Special case for both values.
		//Create new node
		if( isFloat( ptr ) )
		{
			uint64_t iLhs = (uint64_t)m_FloatConstantPool[ ptr->iIndex ];
			if ( isFloat( nodetree->rhsNode ) )
			{
				int64_t iRhs = (int64_t)m_FloatConstantPool[ nodetree->rhsNode->iIndex ];
				ptr = emitLoadStack( integerConstant( iLhs OP iRhs ) );
				delete ptr;
				return nodetree;
			}
			else
			{
				int64_t iRhs = (int64_t)m_IntegerConstantPool[ nodetree->rhsNode->iIndex ];
				ptr = emitLoadStack( integerConstant( iLhs OP iRhs ) );
				delete ptr;
				return nodetree;
			}
		}
		else
		{
			uint64_t iLhs = m_IntegerConstantPool[ ptr->iIndex ];
			if ( isFloat( nodetree->rhsNode ) )
			{
				int64_t iRhs = (int64_t)m_FloatConstantPool[ nodetree->rhsNode->iIndex ];
				ptr = emitLoadStack( integerConstant( iLhs OP iRhs ) );
				delete ptr;
				return nodetree;
			}
			else
			{
				int64_t iRhs = m_IntegerConstantPool[ nodetree->rhsNode->iIndex ];
				ptr = emitLoadStack( integerConstant( iLhs OP iRhs ) );
				delete ptr;
				return nodetree;
			}
		}	
	}

	//Left hand side
	emitLoadStack( ptr );

	//Right hand side
	ptr = nodetree->rhsNode;
	emitLoadStack( ptr );

	//shiftRightUnsigned 2 stack entries
	emit( CEE_SHR_UN );

	return nodetree;
}
void MessagePackAdaptorTests::testFloat() {
    // Negative
    {
        pack(Datum(-1.5));
        auto o = unpack();
        CPPUNIT_ASSERT_EQUAL( msgpack::type::FLOAT, o.type );
        auto d = o.as<Datum>();
        CPPUNIT_ASSERT( d.isFloat() );
        CPPUNIT_ASSERT_EQUAL( -1.5, d.getFloat() );
    }

    // Zero
    {
        pack(Datum(0.0));
        auto o = unpack();
        CPPUNIT_ASSERT_EQUAL( msgpack::type::FLOAT, o.type );
        auto d = o.as<Datum>();
        CPPUNIT_ASSERT( d.isFloat() );
        CPPUNIT_ASSERT_EQUAL( 0.0, d.getFloat() );
    }

    // Positive
    {
        pack(Datum(2.5));
        auto o = unpack();
        CPPUNIT_ASSERT_EQUAL( msgpack::type::FLOAT, o.type );
        auto d = o.as<Datum>();
        CPPUNIT_ASSERT( d.isFloat() );
        CPPUNIT_ASSERT_EQUAL( 2.5, d.getFloat() );
    }
}
Exemple #4
0
Match matchType(BasicType lhs, BasicType rhs) {
    if (lhs == rhs)
        return Match::Exact;

    if (isNumeric(lhs) && isNumeric(rhs)) {
        const u16_t lhs_size = BasicTypeSize[static_cast<u16_t>(lhs)];
        const u16_t rhs_size = BasicTypeSize[static_cast<u16_t>(rhs)];

        if (isIntegral(lhs) && isIntegral(rhs)) {
            if (isSigned(lhs) == isSigned(rhs)) {
                if (lhs_size >= rhs_size)
                    return Match::Exact;
            }

            return Match::Convert;
        }

        if (isFloat(lhs) && isFloat(rhs)) {
            if (lhs_size >= rhs_size)
                return Match::Exact;
            return Match::Convert;
        }

        if (isFloat(lhs) && isIntegral(rhs)) {
            if (lhs_size >= rhs_size)
                return Match::Exact;
            return Match::Convert;
        }
    }

    return Match::No;
}
Exemple #5
0
void test_function_is_float()
{
  float len1=100,len2=100.1212;

  TEST_ASSERT_EQUAL(0,isFloat( len1 ));
  TEST_ASSERT_EQUAL(1,isFloat( len2 ));

}
void Token::setType(){
	char operators[] = {'+', '-', '*', '/', '^'};
	if(token_string.size() == 1){
		if(token_string[0] == 't'){
			is_partial = false;
			token_type = ID_VAR;
			return;
		}
		if(token_string[0] == '@'){
			is_partial = false;
			token_type = ID_FUNCTION;
			return;
		}
		if(token_string[0] == '(' || token_string[0] == ')'){
			is_partial = false;
			token_type = ID_PAREN;
			return;
		}
		for(unsigned int i = 0; i < sizeof(operators)/sizeof(operators[0]); i++){
			if(token_string[0] == operators[i]){
				is_partial = false;
				token_type = ID_OPERATOR;
				if(operators[i] == '+' || operators[i] == '-'){
					precedence = 0;
					is_left_assoc = true;
				}
				if(operators[i] == '*' || operators[i] == '/'){
					precedence = 1;
					is_left_assoc = true;
				}
				if(operators[i] == '^'){
					precedence = 2;
					is_left_assoc = false;
				}
				return;
			}
		}
		//If it gets here, it's neither an operator nor a variable
		if(isFloat(token_string) || token_string[0] == '.'){
			token_type = ID_NUMBER;
		}
	}
	else if(token_string.size() > 1){
		if(isFloat(token_string)){
			token_type = ID_NUMBER;
		}
	}
}
Exemple #7
0
void AtomContainer::addAtom(const double * pos, const std::vector<std::string>& atomProperties){
	int iProperty;
	//after adding the atom was successful, continue with adding additional properties
	if(addAtom(pos)) {
		//save additional properties
		for (iProperty = 0; iProperty < atomProperties.size(); iProperty++){
			if (!atomPropertyList.isPropertyInt(iProperty)) {
				//property has float type
				atomPropertyList.addFloatPropertyValue(iProperty, atof(atomProperties[iProperty].c_str()));
			} else {
				//property has integer type
				if (isFloat(atomProperties[iProperty])) {
					//but current value is of float type -> conversion
					atomPropertyList.convertPropertyToFloat(iProperty);
					atomPropertyList.addFloatPropertyValue(iProperty, atof(atomProperties[iProperty].c_str()));
				} else {
					//value has also integer type -> add value
					atomPropertyList.addIntPropertyValue(iProperty,atoi(atomProperties[iProperty].c_str()));
				}
			}
		}
	} else {
		std::cout << "WARNING: Adding atom " << getNumAtoms() <<" failed (placed outside container)" << std::endl;
	}
}
Exemple #8
0
 bool isNumber(const char *s) {
     int left = 0, right = strlen(s) - 1;
     while(left <= right && (s[left] == ' ' || s[left] == '\t' || s[left] == '\n')) {
         ++ left;
     }
     while(left <= right && (s[right] == ' ' || s[right] == '\t' || s[right] == '\n')) {
         -- right;
     }
     if (left > right) return false;
     int cnt_dot = 0, cnt_e = 0, pos_e = 0;
     for (int i = left; i <= right; ++i) {
         if (!('0' <= s[i] && s[i] <= '9')) {
             if (s[i] == '.') {
                 ++ cnt_dot;
             } else if (s[i] == 'e' || s[i] == 'E'){
                 ++ cnt_e;
                 pos_e = i;
             } else if (s[i] != '-' && s[i] != '+'){
                 return false;
             }
         }
     }
     if (cnt_e > 1 || cnt_dot > 1) {
         return false;
     }
     if ((cnt_e && isFloat(s, left, pos_e - 1) && isInt(s, pos_e + 1, right)) || (!cnt_e && isFloat(s, left, right))) {
         return true;
     }
     return false;
 }
void str::operator-=(float n)
{
    if(isFloat())
    {
        (*this) = (float)str::toFloat(mpStr) - n; // Call Assignment Operator for float
    }
}
/***************************************************************************
 * emit unaryPlus Operation
  ***************************************************************************/
CCgNodeData* CCilCodeGen::emitUnaryPlusOperator( CCgNodeData* nodetree )
{
    assert( nodetree != NULL );
    assert( nodetree->NodeType == CG_NODE_FORMULANODE );
    assert( nodetree->lhsNode != NULL );
    assert( nodetree->rhsNode == NULL );

    CCgNodeData* ptr = nodetree->lhsNode;
    if( isValue( ptr ) )
    {
        //Special case for both values.
        //Create new node
        if( isFloat( ptr ) )
        {
            double dLhs = m_FloatConstantPool[ ptr->iIndex ];
            ptr = emitLoadStack( floatConstant( OP dLhs ) );
            delete ptr;
            return nodetree;
        }
        else
        {
            int64_t iLhs = m_IntegerConstantPool[ ptr->iIndex ];
            ptr = emitLoadStack( integerConstant( OP iLhs ) );
            delete ptr;
            return nodetree;
        }
    }

    //Left hand side
    emitLoadStack( ptr );
    emit( CEE_EXT_STARGLIST_S, (uint8_t)1 );	//Move to arglist
    emit( CEE_CALL, m_ridMethodToNumber );		//Function Object Constructor

    return nodetree;
}
Exemple #11
0
int main()
{
    char str[1024];

    while(gets(str)!=NULL && strcmp(str,"#"))/*/空行/*/
        printf("%s\n",isFloat(str)?"Yes":"No");
}
Exemple #12
0
//----------------------------------------------------------
float List::getFloat(const unsigned int index) const {
	if(!isFloat(index)) {
		std::cerr << "Pd: List: object " << index << " is not a float" << std::endl;
		return 0;
	}
	return objects[index].value;
}
Exemple #13
0
// parse the string, returning the number of floats
// that have been in the string.
bool
htmInterface::parseVec( cmdCode code, float64 *v) {

  VarStr  token;
  size_t  i = 0, len;

  if(code == J2000)
    len = 2;
  else if(code == CARTESIAN)
    len = 3;
  else
    throw SpatialInterfaceError("htmInterface:parseVec: Expected code J2000 or CARTESIAN.");

  // parse the next len positions
  while( i < len  ) {
    token = t_->next();
    if(token.empty())break;

    if(!isFloat(token))
      throw SpatialInterfaceError("htmInterface:parse: Expected float at this position of Command. ",cmd_.data());
    if(i == len)
      throw SpatialInterfaceError("htmInterface:parse: Expect less floats in Command. ", cmd_.data());
    v[i++] = atof(token.data());
  }

  if(i < len)
    return false;
  return true;

}
Exemple #14
0
    bool AsmJsType::isSubType(AsmJsType type) const
    {
        switch (type.which_)
        {
        case Js::AsmJsType::Double:
            return isDouble();
            break;

        case Js::AsmJsType::MaybeDouble:
            return isMaybeDouble();
            break;
        case Js::AsmJsType::DoubleLit:
            return isDoubleLit();
            break;
        case Js::AsmJsType::Float:
            return isFloat();
            break;
        case Js::AsmJsType::MaybeFloat:
            return isMaybeFloat();
            break;
        case Js::AsmJsType::Floatish:
            return isFloatish();
            break;
        case Js::AsmJsType::FloatishDoubleLit:
            return isFloatishDoubleLit();
            break;
        case Js::AsmJsType::Fixnum:
            return which_ == Fixnum;
            break;
        case Js::AsmJsType::Int:
            return isInt();
            break;
        case Js::AsmJsType::Signed:
            return isSigned();
            break;
        case Js::AsmJsType::Unsigned:
            return isUnsigned();
            break;
        case Js::AsmJsType::Intish:
            return isIntish();
            break;
        case Js::AsmJsType::Void:
            return isVoid();
            break;
        case AsmJsType::Int32x4:
            return isSIMDInt32x4();
            break;
        case AsmJsType::Float32x4:
            return isSIMDFloat32x4();
            break;
        case AsmJsType::Float64x2:
            return isSIMDFloat64x2();
            break;
        default:
            break;
        }
        return false;
    }
int ParseProfLine(const char *pchIn, long *plAddress, int *piSamples, float *pfPercentage)
{
  char chVal[128], *pchOut;
  
  /* skip any initial whitespace */
  while (isSpace(*pchIn)) pchIn++;
  if (!isHex(*pchIn)) return 0;
  
  /* parse hexadecimal address value */
  pchOut = chVal;
  while (isHex(*pchIn)) *pchOut++ = *pchIn++;
  *pchOut = 0;
  if (!isSpace(*pchIn)) return 0;
  *plAddress = strtol(chVal, NULL, 16);
  
  /* skip more whitespace */
  while (isSpace(*pchIn)) pchIn++;
  if (!isNum(*pchIn)) return 0;
  
  /* parse decimal sample count value */
  pchOut = chVal;
  while (isNum(*pchIn)) *pchOut++ = *pchIn++;
  *pchOut = 0;
  if (!isSpace(*pchIn)) return 0;
  *piSamples = atoi(chVal);
  
  /* skip more whitespace */
  while (isSpace(*pchIn)) pchIn++;
  if (!isFloat(*pchIn)) return 0;
  
  /* parse floating-point percentage value */
  pchOut = chVal;
  while (isFloat(*pchIn)) *pchOut++ = *pchIn++;
  *pchOut = 0;
  if (!isSpace(*pchIn) && *pchIn != '\r' && *pchIn != '\n' && *pchIn != 0) return 0;
  *pfPercentage = atof(chVal);

  /* if this isn't the end of the line, it's not a valid sample point */
  while (isSpace(*pchIn)) pchIn++;
  if (*pchIn != '\r' && *pchIn != '\n' && *pchIn != 0) return 0;
 
  return 1;
}
void OSCServerThread::run()
{
        oscpkt::UdpSocket server;
        server.bindTo(this->port);
        if (!server.isOk()) {
                std::cerr << "Error opening OSC server at " << port
                          << std::endl;
                return;
        }

        std::cout << "Started OSC Server at " << port << std::endl;

        oscpkt::PacketReader reader;
        oscpkt::PacketWriter writer;
        while (server.isOk() && !mustQuit) {
                if (server.receiveNextPacket(30)) {
                        reader.init(server.packetData(), server.packetSize());
                        oscpkt::Message *msg;
                        while (reader.isOk() &&
                               (msg = reader.popMessage()) != 0) {
                                QVariantList message;
                                message.append(QString::fromStdString(
                                    msg->addressPattern()));
                                auto args = msg->arg();
                                while (!args.isOkNoMoreArgs()) {
                                        if (args.isInt32()) {
                                                int32_t i;
                                                args = args.popInt32(i);
                                                message.append(i);
                                        } else if (args.isInt64()) {
                                                int64_t i;
                                                args = args.popInt64(i);
                                                message.append(
                                                    static_cast<qlonglong>(i));
                                        } else if (args.isFloat()) {
                                                float f;
                                                args = args.popFloat(f);
                                                message.append(f);
                                        } else if (args.isDouble()) {
                                                double d;
                                                args = args.popDouble(d);
                                                message.append(d);
                                        } else if (args.isStr()) {
                                                std::string s;
                                                args = args.popStr(s);
                                                message.append(
                                                    QString::fromStdString(s));
                                        }
                                }
                                emit messageIn(message);
                        }
                }
        }
}
void Waifu2x_Process_Base::process_core_rgb()
{
    FLType *dstYd = nullptr, *dstUd = nullptr, *dstVd = nullptr;
    FLType *srcYd = nullptr, *srcUd = nullptr, *srcVd = nullptr;

    // Get write/read pointer
    auto dstR = reinterpret_cast<_Ty *>(vsapi->getWritePtr(dst, 0));
    auto dstG = reinterpret_cast<_Ty *>(vsapi->getWritePtr(dst, 1));
    auto dstB = reinterpret_cast<_Ty *>(vsapi->getWritePtr(dst, 2));

    auto srcR = reinterpret_cast<const _Ty *>(vsapi->getReadPtr(src, 0));
    auto srcG = reinterpret_cast<const _Ty *>(vsapi->getReadPtr(src, 1));
    auto srcB = reinterpret_cast<const _Ty *>(vsapi->getReadPtr(src, 2));

    // Allocate memory for floating point YUV data
    AlignedMalloc(dstYd, dst_pcount[0]);
    if (d.chroma) AlignedMalloc(dstUd, dst_pcount[1]);
    if (d.chroma) AlignedMalloc(dstVd, dst_pcount[2]);

    AlignedMalloc(srcYd, src_pcount[0]);
    AlignedMalloc(srcUd, src_pcount[1]);
    AlignedMalloc(srcVd, src_pcount[2]);

    // Convert src and ref from RGB data to floating point YUV data
    RGB2FloatYUV(srcYd, srcUd, srcVd, srcR, srcG, srcB,
        src_height[0], src_width[0], src_stride[0], src_stride[0],
        d.para.matrix, d.para.full, false);

    // Execute kernel
    if (d.chroma)
    {
        Kernel(dstYd, dstUd, dstVd, srcYd, srcUd, srcVd);
    }
    else
    {
        Kernel(dstYd, srcYd);
        dstUd = srcUd;
        dstVd = srcVd;
    }

    // Convert dst from floating point YUV data to RGB data
    FloatYUV2RGB(dstR, dstG, dstB, dstYd, dstUd, dstVd,
        dst_height[0], dst_width[0], dst_stride[0], dst_stride[0],
        d.para.matrix, d.para.full, !isFloat(_Ty));

    // Free memory for floating point YUV data
    AlignedFree(dstYd);
    if (d.chroma) AlignedFree(dstUd);
    if (d.chroma) AlignedFree(dstVd);

    AlignedFree(srcYd);
    AlignedFree(srcUd);
    AlignedFree(srcVd);
}
Exemple #18
0
qboolean HStorage_StringToValue(varType_t type, char* string, vsValue_t* value)
{
    switch(type)
    {
        default:
            memset(value, 0, sizeof(vsValue_t));
            return qfalse;

        case VSVAR_STRING:
            value->string = string;
            return qtrue;

        case VSVAR_BOOLEAN:
            if(!isInteger(string, 0))
            {
                value->boolean = 0;
                return qfalse;
            }
            value->boolean = atoi(string);
            if(value->boolean != 0 && value->boolean != 1)
            {
                return qfalse;
            }
            return qtrue;

        case VSVAR_INTEGER:
            if(!isInteger(string, 0))
            {
                value->integer = 0;
                return qfalse;
            }
            value->integer = atoi(string);
            return qtrue;

        case VSVAR_FLOAT:
            if(!isFloat(string, 0))
            {
                value->floatVar = 0.0;
                return qfalse;
            }
            value->floatVar = atof(string);
            return qtrue;

        case VSVAR_VECTOR:
            if(!isVector(string, 0, 3))
            {
                memset(value, 0, sizeof(vsValue_t));
                return qfalse;
            }
            strToVect(string, value->vector, 3);
            return qtrue;
    }

}
Exemple #19
0
int
validateFloat (float *value, const char *string, const float *minimum, const float *maximum) {
  if (*string) {
    float f;
    if (!isFloat(&f, string)) return 0;
    if (minimum && (f < *minimum)) return 0;
    if (maximum && (f > *maximum)) return 0;
    *value = f;
  }
  return 1;
}
Exemple #20
0
 bool isNumber(const char *s) {
     // Start typing your C/C++ solution below
     // DO NOT write int main() function
     int l = 0, r = strlen(s);
     while (l < r && s[l] == ' ') l++;
     while (l < r && s[r - 1] == ' ') r--;
     if (l >= r) return false;
     if (isInteger(s, l, r)) return true;
     if (isFloat(s, l, r)) return true;
     if (isScitific(s, l, r)) return true;
     return false;
 }
Exemple #21
0
// get an integer out of the command string
float64 htmInterface::getFloat() {

  if(!t_)
    throw SpatialFailure("htmInterface:getFloat: No command to parse");

  // parse incoming string. expect to have an integer.
  const VarStr &token = t_->next();
  if(!isFloat(token))
    throw SpatialInterfaceError("htmInterface:getFloat: Expected float at first position of Command. ",cmd_.data());

  return atof(token.data());
}
Exemple #22
0
Value::operator double() const {
    if(isString()){
        return Math::toDouble(this->sValue);
    } else if(isInteger()) {
        return (double)(this->iValue);
    } else if(isFloat()) {
        return (double)(this->fValue);
    } else if(isDouble()) {
        return this->dValue;
    }
    throw Exception("Value not found, the type is (" + std::to_string(this->type) + ")");
}
Exemple #23
0
void genOperation(FILE* yyout, Symbol* leftSide, Symbol* rightSide, char* op )
{
	int r0, r1;
	r0 = ((ExtraInfo*)(leftSide->info))->nRegister;
	r1 = ((ExtraInfo*)(rightSide->info))->nRegister;
	int isFloat_ = isFloat( leftSide );

	if( !isFloat_ ){
		if(r0 == 7){
			r0 = assignRegisters(0);
			if (r0 == -1){
				r0 = checkOverflow(yyout, r0, TYPE_INTEGER);
			}
			((ExtraInfo*)(leftSide->info))->nRegister = r0;
			extraInfoPerRegister[r0] = ((ExtraInfo*)(leftSide->info));
			fprintf(yyout, "\tR%d = I(R7);\t//Recovering value from stack\n\tR7 = R7 + 4;\n", r0);
		}
		if(r1 == 7){
			r1 = assignRegisters(0);
			if (r1 == -1){
				r1 = checkOverflow(yyout, r1, TYPE_INTEGER);
			}
			((ExtraInfo*)(leftSide->info))->nRegister = r1;
			extraInfoPerRegister[r1] = ((ExtraInfo*)(rightSide->info));
			fprintf(yyout, "\tR%d = I(R7);\t//Recovering value from stack\n\tR7 = R7 + 4;\n", r1);
		}
		fprintf(yyout, "\tR%d = R%d %s R%d;\n", r0, r0,op, r1);
	}else{
		if(r0 == 77){
			r0 = assignRegisters(1);
			if (r0 == -1){
				r0 = checkOverflow(yyout, r0, TYPE_FLOAT);
			}
			((ExtraInfo*)(leftSide->info))->nRegister = r0;
			extraInfoPerDoubleRegister[r0] = ((ExtraInfo*)(leftSide->info));
			fprintf(yyout, "\tRR%d = F(R7);\t//Recovering value from stack\n\tR7 = R7 + 4;\n", r0);
		}
		if(r1 == 77){
			r1 = assignRegisters(1);
			if (r1 == -1){
				r1 = checkOverflow(yyout, r1, TYPE_FLOAT);
			}
			((ExtraInfo*)(leftSide->info))->nRegister = r1;
			extraInfoPerDoubleRegister[r1] = ((ExtraInfo*)(rightSide->info));
			fprintf(yyout, "\tRR%d = F(R7);\t//Recovering value from stack\n\tR7 = R7 + 4;\n", r1);
		}
		fprintf(yyout, "\tRR%d = RR%d %s RR%d;\n", r0, r0,op, r1);
	}
	
	freeRegister( r1, isFloat_ );
	freeSymbol(rightSide);
}
bool FunctionsFactory::isXFunction(string source){
	string temp = source.substr(0, source.length()-1 );
	if(source[source.length()-1] == 'x'){
		if(source.length() > 1){
			if(isFloat(temp)){
				return true;
			}
		}else{
			return true;
		}
	}
	return false;
}
Exemple #25
0
// Generate the code for a parameter pass. Arguments:
// - iRegister - index of register with the argument's value.
// - method - called method symbol.
// - iArgument - argument index.
void genArgumentPass( FILE* yyout, Symbol* argumentSymbol, Symbol* method, int iArgument )
{
	Symbol* argument = getMethodArgument( method, iArgument );
	int iRegister = ((ExtraInfo*)(argumentSymbol->info))->nRegister;
	int address = ((Variable*)( argument->info ) )->address;

	int isFloat_ = isFloat( argumentSymbol );
	cstr regStr = getRegStr( isFloat_ );

	// Get parameter.
	fprintf( yyout,"\t%c(R7+%d) = %s%d;\t// %iº Argument\n", pointerType( argument ), address, regStr, iRegister, iArgument+1 );
	freeRegister( iRegister, isFloat_ );
	freeSymbol(argumentSymbol);
}
void AddStock::validate()
{
    // Check of syntax of quantities
    QRegExp regex("^-?[0-9]+$");
    QString tmpString;
    for(unsigned i =0 ; i < numberOfLines ; i++)
    {
        tmpString = lines[i]->quantity.text();
        if(!tmpString.contains(regex))
        {
            error->showMessage("La quantité rentrée à la ligne " + QString::number(i+1) + " ("+lines[i]->product.currentText() +") n'est pas valide. Ce doit être un entier relatif.");
            return;
        }
    }

    // Generating the queue to send to controller
    view_productQueue queue;
    view_productTuple tuple;
    for (unsigned i =0 ; i <numberOfLines ; i++)
    {
        tuple.setProductCategory(lines[i]->consoType.currentIndex() + 1); // 0 is reserved for +/-
        tuple.setProductId(lines[i]->productID[lines[i]->product.currentIndex()]);
        tuple.setProductName(lines[i]->product.currentText());
        tuple.setProductStock(lines[i]->quantity.text().toInt());
        queue.push(tuple);
        delete[] lines[i]->productID;
    }
    if(!isFloat(tvaTotal->text()) || !isFloat(ttcTotal->text()))
        return;
    float tva = tvaTotal->text().toFloat();
    float ttc = ttcTotal->text().toFloat();
    controller->receiveNewStocks(queue,tva, ttc, infos->text());
    this->reset();
    this->hide();

}
Exemple #27
0
void LogicAnalyzerDisplay::updateData(const int channel, const Pothos::Packet &packet)
{
    //column count changed? new labels
    const size_t numElems = packet.payload.elements();
    const bool changed = _tableView->columnCount() != int(numElems);
    _tableView->setColumnCount(numElems);
    if (changed) this->updateHeaders();

    const auto dtype = packet.payload.dtype;
    if (dtype.isComplex()) this->populateChannel<std::complex<qreal>>(channel, packet);
    else if (dtype.isFloat()) this->populateChannel<qreal>(channel, packet);
    else if (dtype.isInteger()) this->populateChannel<qlonglong>(channel, packet);

    if (changed) _tableView->resizeColumnsToContents();
}
Exemple #28
0
/* virtual */ void
av::osg::Uniform::getValuesCB(const av::MFFloat::GetValueEvent& event)
{
  av::MFFloat::ContainerType& container(*event.getValuePtr());
  container.clear();
  unsigned int size = mOsgUniform->getTypeNumComponents(mOsgUniform->getType());
  if (isFloat(mOsgUniform->getType())) {
    ::osg::FloatArray* fa = mOsgUniform->getFloatArray();
    for (unsigned int i = 0; i < size; ++i) {
      container.push_back((*fa)[i]);
    }
  } else {
    ::osg::IntArray* ia = mOsgUniform->getIntArray();
    for (unsigned int i = 0; i < size; ++i) {
      container.push_back((float)(*ia)[i]);
    }
  }
}
bool Token::appendStr(char c){
	if(is_partial){
		if(c == '@') return false;//It's a function
		if(token_type == ID_NUMBER){
			//Does adding the char to this make it a number? If so, add the char to the token string and return true
			if(isFloat(token_string + c)){
				token_string += c;
				return true;
			}
			else{
				return false;
			}
		}
		token_string += c;
		setType();
	}
	return false;
}
Exemple #30
0
std::string List::toString() const {

	std::string line;
	std::stringstream itoa;

	for(int i = 0; i < objects.size(); ++i) {
		if(isFloat(i)) {
			itoa << getFloat(i);
			line += itoa.str();
			itoa.str("");
		}
		else
			line += getSymbol(i);
		line += " ";
	}

	return line;
}