Exemple #1
0
Bomb::Bomb(Position<char> targetPosition, unsigned int maxLines, unsigned int maxColumns)
{
	
	switch (rand() % 5)
	{
	case 1:
		targetPosition.column = targetPosition.column + 1;
		targetPosition.line = targetPosition.line;
		break;
	case 2:
		targetPosition.column = targetPosition.column - 1;
		targetPosition.line = targetPosition.line;
		break;
	case 3:
		targetPosition.column = targetPosition.column;
		targetPosition.line = targetPosition.line + 1;
		break;
	case 4:
		targetPosition.column = targetPosition.column;
		targetPosition.line = targetPosition.line - 1;
		break;
	}

	targetPosition.column = Maximum(targetPosition.column, 'a');
	targetPosition.line = Maximum(targetPosition.line, 'A');
	targetPosition.column = Minimum(targetPosition.column, maxColumns + 'a' - 1);
	targetPosition.line = Minimum(targetPosition.line, maxLines + 'A' - 1);
	
	target = targetPosition;
}
Exemple #2
0
suic::Size Slider::ArrangeOverride(const suic::Size& size)
{
    suic::Rect rcdraw(0, 0, size.cx, size.cy);
    const suic::Size& thumbSize = _thumbBtn->GetDesiredSize();

    // 水平
    if (GetOrientation() == CoreFlags::Horizontal)
    {
        int len = rcdraw.right - rcdraw.left - thumbSize.cx;

        rcdraw.left = rcdraw.left 
            + (LONG)(len * (GetValue() - Minimum()) / (Maximum() - Minimum()));
        rcdraw.right = rcdraw.left + thumbSize.cx;
    }
    else
    {
        int len = rcdraw.bottom - rcdraw.top - thumbSize.cy;

        rcdraw.top = rcdraw.bottom - thumbSize.cy 
            - (LONG)(len * (GetValue() - Minimum()) / (Maximum() - Minimum()));
        rcdraw.bottom = rcdraw.top + thumbSize.cy;
    }
   
    _thumbBtn->Arrange(rcdraw);

    return size;
}
        void Preferences::applyDefaults() {
            fl::Engine* engine = Model::Default()->engine();

            if (engine->numberOfRuleBlocks() == 0) {
                QMessageBox::critical(this, "Error",
                        "Current engine has no rule blocks. "
                        "At least one ruleblock was expected.",
                        QMessageBox::Ok);
                return;
            }
            std::string tnorm = Minimum().className();
            std::string snorm = Maximum().className();
            std::string activation = Minimum().className();

            RuleBlock* ruleblock = engine->getRuleBlock(0);
            if (ruleblock->getTnorm()) tnorm = ruleblock->getTnorm()->className();
            if (ruleblock->getSnorm()) snorm = ruleblock->getSnorm()->className();
            if (ruleblock->getActivation()) activation = ruleblock->getActivation()->className();

            std::string defuzzifier = Centroid().className();
            int divisions = fl::fuzzylite::defaultDivisions();
            std::string accumulation = Maximum().className();

            if (engine->numberOfOutputVariables() > 0) {
                OutputVariable* variable = engine->getOutputVariable(0);
                if (variable->getDefuzzifier()) {
                    defuzzifier = variable->getDefuzzifier()->className();
                    divisions = variable->getDefuzzifier()->getDivisions();
                }
                if (variable->output()->getAccumulation())
                    accumulation = variable->output()->getAccumulation()->className();
            }
            engine->configure(tnorm, snorm, activation, accumulation, defuzzifier, divisions);
        }
Exemple #4
0
char *DBGridIF::ValueFormat() const {
    switch (DataPTR->Type()) {
        case DBTypeGridDiscrete:
            return ((char *) "%s");
        case DBTypeGridContinuous:
            return (DBMathFloatAutoFormat(fabs(Maximum()) > fabs(Minimum()) ? Maximum() : Minimum()));
        default:
            return ((char *) NULL);
    }
}
Exemple #5
0
/*
*Concatenate: Adds a new array onto the end of the original array. 
*Parameters: A DynamicArray object.
*Return Value: N/A
*/
void DynamicArray::Concatenate(DynamicArray darr){
    int *conarrayPtr;
    int newsize = size + darr.size;
    
    conarrayPtr = new int [newsize];
    
    for(int i = 0; i < size; i++){
        *(conarrayPtr+i) = *(arrayPtr+i);
    }
    
    for(int i = size; i < newsize; i++){
        *(conarrayPtr+i) = *((darr.arrayPtr)+i);
    }
    
    //deallocates the arrayPtr
    delete [] arrayPtr;
    //Assigns conarrayPtr to arrayPtr
    arrayPtr = conarrayPtr;
    
    size = newsize;
    
    Display();
    Minimum();
    Maximum();
}
Exemple #6
0
/*
*SubArray:  Creates a new array which hs a size of the difference between to elements.  All elements between the two positions passed in are stored in the new array.  The new array replaces the orignal array.
*Parameters:  Two integers between 0 and array size-1.
*Return Value:  N/A
*/
void DynamicArray::SubArray(int a, int b){
    int *subarrayPtr;
    int subsize;
    //Assures a positive value.
    if(b <= size - 1) {
        if (a >= 0 && a <= b) {
            subsize = (b - a) + 1;
        }
        
        subarrayPtr = new int [subsize];
        
        //Copies elements of original array to new array.
        for(int i = 0; i < b; i++){
            *(subarrayPtr+i) = *(arrayPtr+(a+i)); 
        }
        
        //deallocates the arrayPtr
        delete [] arrayPtr;
        //Assigns subarray to arrayPtr
        arrayPtr = subarrayPtr;
        size = subsize;
    }
    
    Display();
    Minimum();
    Maximum();
}
void RGB_To_HSV( double r, double g, double b, double *h, double *s, double *v )
{
/*
 * given: rgb, each in [0,1]
 * desired: h in [0,360), s and v in [0,1] except if s = 0 then h = undefined
 */
    double max = Maximum( r, g, b );
    double min = Minimum( r, g, b );
    *v = max;                           /*This is the value v. */
    /* Next calculate saturation, s. Saturation is 0 if red, green and blue are all 0 */
    *s = (max != 0.0) ? ( (max-min)/max ) : 0.0;
    if (*s == 0.0) {
        *h = UNDEFINED;
    } else {
        /*Chromatic case: Saturation is not 0*/
        double delta = max-min;           /*Determine Hue*/
        if (r == max)
            *h = (g-b)/delta;                  /* resulting color is between yellow and magenta */
        else if (g == max)
            *h = 2.0+(b-r)/delta;                    /* resulting color is between cyan and yellow */
        else if (b == max)
            *h = 4.0+(r-g)/delta;                   /* resulting color is between magenta and cyan */
        *h *= 60.0;                             /*convert hue to degrees*/
        if (*h < 0.0)
            *h += 360.0;                        /*make sure its not negative*/
    }
}
	SDL_Rect Intersection(const SDL_Rect& a, const SDL_Rect& b) {
		int x1 = Maximum(a.x, b.x);
		int y1 = Maximum(a.y, b.y);
		int x2 = Minimum(a.x + a.w, b.x + b.w);
		int y2 = Minimum(a.y + a.h, b.y + b.h);

		int width = x2 - x1;
		int height = y2 - y1;

		if(width > 0 && height > 0) {
			SDL_Rect intersect = {x1, y1, width, height};
			return intersect;
		} else {
			SDL_Rect intersect = {0, 0, 0, 0};
			return intersect;
		}
	}
Exemple #9
0
void Slider::HandleHorizontal(int pos)
{
    suic::Rect rcItem(0, 0, RenderSize().cx, RenderSize().cy);
    const suic::Size& thumbSize = _thumbBtn->GetDesiredSize();

    if (pos >= rcItem.right - thumbSize.cx) 
    {
        SetValue(Maximum());
    }
    else if (pos <= rcItem.left) 
    {
        SetValue(Minimum());
    }
    else 
    {
        SetValue(Minimum() + (Maximum() - Minimum()) * (double)(pos) / (double)(rcItem.Width() - thumbSize.cx));
    }
}
/*****************************************************************************
* Function: WeightedPathfinding - Constructor
*
* Description: Allocates and initializes the cell data
*****************************************************************************/
WeightedPathfinding::WeightedPathfinding
	(
		Maze* m
	)
{
	m->Map(WeightedPathfinding::InitializeCellData);
	maze_max_dim = Maximum(MAZE_NUM_ROWS, MAZE_NUM_COLS);
	this->m = m;
} // WeightedPathfinding()
Exemple #11
0
void Slider::HandleVertical(int pos)
{
    suic::Rect rcItem(0, 0, RenderSize().cx, RenderSize().cy);
    const suic::Size& thumbSize = _thumbBtn->GetDesiredSize();

    if (pos <= rcItem.top ) 
    {
        SetValue(Minimum());
    }
    else if (pos >= rcItem.bottom - thumbSize.cy) 
    {
        SetValue(Maximum());
    }
    else 
    {
        SetValue(Minimum() + (Maximum() - Minimum()) * (double)(pos) / (double)(rcItem.Height() - thumbSize.cy));
    }
}
Exemple #12
0
int hauteur(const Abin a)
{
	int Maximum(const int a, const int b);

	if (estVide(a))
	{
		return 0;
	}
	return 1 + Maximum(hauteur(gauche(a)), hauteur(droite(a)));
}
Exemple #13
0
int main()
{
	freopen("monkeyk.in","r",stdin);
	freopen("monkeyk.out","w",stdout);
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		father[i]=i;
		scanf("%d",&mem[i].key);
		Heap[i]=i;
	}
	scanf("%d",&M);
	while(M--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if (same(x,y)) printf("-1\n");
		else
		{
			int fx=getfather(x),fy=getfather(y);
			judge(fx,fy);
			
			int t;
			int p=Maximum(Heap[fx]);
			t=del(Heap[fx],p);
			Heap[fx]=Union(t,Heap[fx]);
			mem[p].key/=2;
			Heap[fx]=insert(Heap[fx],p);
			p=Maximum(Heap[fy]);
			
			t=del(Heap[fy],p);
			Heap[fy]=Union(t,Heap[fy]);
			mem[p].key/=2;
			Heap[fy]=insert(Heap[fy],p);
			
			Heap[fx]=Union(Heap[fx],Heap[fy]);
			Heap[fy]=NULL;
			printf("%d\n",mem[Maximum(Heap[fx])].key);
		}
	}
	return 0;
}
Exemple #14
0
 SNormFactory::SNormFactory() : ConstructionFactory<SNorm*>("SNorm") {
     registerConstructor("", fl::null);
     registerConstructor(AlgebraicSum().className(), &(AlgebraicSum::constructor));
     registerConstructor(BoundedSum().className(), &(BoundedSum::constructor));
     registerConstructor(DrasticSum().className(), &(DrasticSum::constructor));
     registerConstructor(EinsteinSum().className(), &(EinsteinSum::constructor));
     registerConstructor(HamacherSum().className(), &(HamacherSum::constructor));
     registerConstructor(Maximum().className(), &(Maximum::constructor));
     registerConstructor(NilpotentMaximum().className(), &(NilpotentMaximum::constructor));
     registerConstructor(NormalizedSum().className(), &(NormalizedSum::constructor));
 }
Exemple #15
0
void Min_Max_Test()
{
	int n = 102;
	int* arr = new int[n];
	for (int i = 0; i < n; i++)
		arr[i] = i;
	shuffle(arr, n, 100);
	
	Minimum(arr, n);
	Maximum(arr, n);
	Minimum_and_Maximum(arr, n);
}
Exemple #16
0
SDL_Rect Spank::Intersection(const SDL_Rect& boundA, const SDL_Rect& boundB)
{
	int x1 = Maximum(boundA.x, boundB.x);
	int y1 = Maximum(boundA.y, boundB.y);
	int x2 = Minimum(boundA.x + boundA.w, boundB.x + boundB.w);
	int y2 = Minimum(boundA.y + boundA.h, boundB.y + boundB.h);

	int width = x2 - x1;
	int height = y2 - y1;

	if(width > 0 && height > 0)
	{
		SDL_Rect intersect = {x1, y1, width, height};
		return intersect;
	}
	else
	{
		SDL_Rect intersect = {0, 0, 0, 0};
		return intersect;
	}
}
Exemple #17
0
rb_node_t *BST::Predecessor(rb_node_t *z)
{
    rb_node_t *p;
    if (z->left) {
        return Maximum(z->left);
    }
    p = p_of(z);
    while (p && z == p->left) {
        z = p;
        p = p_of(p);
    }
    return p;
}
Exemple #18
0
void Exercise6()
{
	char acTemp[] = "Hello World";
	RevString(acTemp);

	int aiTemp[4] = { 1, 3, 5, 2 };
	CountEven(aiTemp, 4);

	double adTemp[4] = { 1.2, 3.1, 2.7, 7.4 };
	Maximum(adTemp, 4);

	Contains("Look for 'f' please", 'f');
}
void RunningStats::Print(FILE * pFile, const char * header) const
    {
    fprintf (pFile, "\n%s\n", header);
    fprintf (pFile, "NumDataValues:     %ld\n", NumDataValues());
    fprintf (pFile, "Mean:              %f\n", Mean());
    fprintf (pFile, "Variance:          %f\n", Variance());
    fprintf (pFile, "StandardDeviation: %f\n", StandardDeviation());
    fprintf (pFile, "Skewness:          %f\n", Skewness());
    fprintf (pFile, "Kurtosis:          %f\n", Kurtosis());
    fprintf (pFile, "Maximum:           %f\n", Maximum());
    fprintf (pFile, "Minimum:           %f\n", Minimum());
    return;
    }
Exemple #20
0
void Slider::OnKeyDown(suic::KeyEventArg& e)
{
    if (GetOrientation() == CoreFlags::Horizontal) 
    {
        if (e.IsLeftArrow())
        {
            if (GetValue() > Minimum())
            {
                SetValue((int)GetValue() - 1);
            }
        }
        else if (e.IsRightArrow())
        {
            if (GetValue() < Maximum())
            {
                SetValue((int)GetValue() + 1);
            }
        }
    }
    else
    {
        if (e.IsUpArrow())
        {
            if (GetValue() > Minimum())
            {
                SetValue((int)GetValue() - 1);
            }
        }
        else if (e.IsDownArrow())
        {
            if (GetValue() < Maximum())
            {
                SetValue((int)GetValue() + 1);
            }
        }
    }
}
BSTNode<T>* BinarySearchTree<T>::Predecessor(BSTNode<T> *pNode)
{
	if(pNode->pLeft != NULL)									//If the node's left is not NULL, the predecessor is the maximum one in its left sub tree
	{
		return Maximum(pNode->pLeft);
	}
	BSTNode<T>* pTempY = pNode->pParent;						//If the node's left is NULL, the the lowest predecessor is the predecessor and its right child is also the node's predecessor
	BSTNode<T>* pTempX = pNode;
	while((pTempY != NULL) && (pTempY->pLeft == pTempX))
	{
		pTempX = pTempY;
		pTempY = pTempY->pParent;
	}
	return pTempY;
}
Exemple #22
0
main()
{
	int a, b, c, largest;

	setvbuf(stdout, NULL, _IONBF, 0);

	printf("\nProvide the first number to compare: ");
	scanf("%d", &a);
	printf("\nProvide the second number to compare: ");
	scanf("%d", &b);
	printf("\nProvide the third number to compare: ");
	scanf("%d", &c);

	largest = Maximum(a, b, c);

	printf("\nThe largest number is: %d", largest);
}
Exemple #23
0
	SizeInt Viewer::calculateImageSize( ResizeBehaviour mode, float xratio, float yratio, const SizeInt &imageSize, const SizeInt &windowEdges ) {
		wxDisplay display(DisplayFromPointFallback(PositionScreen()));
		auto rtDesktop = wxToRect(display.GetClientArea());

		// The image is larger than the desktop. The image is not supposed
		// to be downscaled so fill the screen.
		if ((mode == ResizeEnlargeOnly) && (xratio < 1.0) && (yratio < 1.0))
			return rtDesktop.Dimensions();
		// The image is smaller than the desktop. It must not be made
		// smaller needlessly so size the window after the image.
		else if ((mode == ResizeReduceOnly) && (xratio > 1.0) && (yratio > 1.0))
			return SizeInt(
				std::max<int>(MinWindowWidth, imageSize.Width + windowEdges.Width),
				std::max<int>(MinWindowHeight,imageSize.Height + windowEdges.Height));

		return Maximum(SizeInt(MinWindowWidth, MinWindowHeight), Minimum(RoundCast(imageSize * std::min(xratio, yratio)) + windowEdges, rtDesktop.Dimensions()));
	}
Exemple #24
0
void ProgressBar::OnTimer(int id)
{
    static double deta = 1;

    double dVal = GetValue() + deta;

    if (dVal > Maximum())
    {
        deta = -1;
        dVal += deta;
    }
    else if (dVal <= SmallChange())
    {
        deta = 1;
        dVal += deta;
    }

    SetValue(dVal);
}
Tree DeleteNode(Tree root, KEY_TYPE value)
{
    if (root == NULL) {
        return NULL;
    }
    if (root->key == value) {
        if (root->lchild == NULL) {
            LinkToChild(&root, root->rchild);
        } else if (root->rchild == NULL) {
            LinkToChild(&root, root->lchild);
        } else {
            Tree maximum = Maximum(root->lchild);
            root->key = maximum->key;
            root->lchild = DeleteNode(root->lchild, root->key);
        }
    } else if (value < root->key) {
        root->lchild = DeleteNode(root->lchild, value);
    } else if (value > root->key) {
        root->rchild = DeleteNode(root->rchild, value);
    }
    return root;
}
bool Entity::TestFloorCollision(Vector3_t oldPos, Vector3_t posDelta, float *tMin)
{
    bool hit = false;
    float tEpsilon = 0.00001f;
    
    // Get the final postion based on the old position and the delta
    float newYPos = oldPos.y + posDelta.y;

    if (newYPos < 0.0f)
    {
        // Now find where along that vector the collision was
        float tResult = (-oldPos.y) / posDelta.y;
        
        // Only use the result if this collision is closer than another one
        if((tResult >= 0.0f) && (*tMin > tResult))
        {
            *tMin = Maximum(0.0f, tResult - tEpsilon);
            hit = true;
        }
    }

    return hit;
}
int Near(int Res1, int Res2, int Res3, int Res4, int Res5, int Res6, int Res7, int Res8,
	 char Cn1, char Cn2, char Cn3, char Cn4, int *DistBest, int *DistWorst)
{

/*
   Res5 Res2 Res1
   Res6 Res3 Res4
*/

  int a, b, c1, d1, c, d, Nei1, Nei2;


  if( Cn1 != Cn2 || Cn3 != Cn4 ) return(FAILURE);


  if( Res1 >= Res2 && Res2 >= Res5 && Res7 >= Res1 && 
      Res4 <= Res3 && Res4 <= Res6 && Res8 <= Res4 ) {

    if( Res5 == Res2 ) 
      Nei1 = Res2;
    else
      Nei1 = Res2-1;
    
    if( Res1 == Res7 ) 
      Nei2 = Res1;
    else
      Nei2 = Res1+1;
    
    a = Nei2-Nei1;
    c1 = Nei2-Res5;
    
    if( Res3 == Res6 ) 
      Nei1 = Res3;
    else
      Nei1 = Res3+1;
    
    if( Res4 == Res8 ) 
      Nei2 = Res4;
    else
      Nei2 = Res4-1;
    
    b = Nei1-Nei2;
    d1 = Res6-Nei2;
  }
  else
    return(FAILURE);
  
  c = Maximum(c1,a);
  d = Maximum(d1,b);
  
  if( a >= 0 && b >= 0 && c >= 0 && d >= 0 && 
      ( (a <= 2 && b <= 5) || (a <= 5 && b <= 2) ) ) {
    *DistBest  = Minimum(a,b);
    *DistWorst = Maximum(c,d);
    if( *DistBest <= *DistWorst ) 
      return(SUCCESS);
    else
      return(FAILURE);
  }
  
  return(FAILURE);
}
Exemple #28
0
ULONG
LZOPTFindMatch (
    IN PUCHAR UncompressedBuffer,
    IN PUCHAR EndOfUncompressedBufferPlus1,
    IN PUCHAR ZivString,
    OUT PUCHAR *MatchedString,
    IN PCOMPRESS_WORKSPACE WorkSpace
    )

/*++

Routine Description:

    This routine does the compression lookup.  It locates
    a match for the ziv within a specified uncompressed buffer.

    If the matched string is two or more characters long then this
    routine does not update the lookup state information.

Arguments:

    UncompressedBuffer - Supplies a pointer to where the uncompressed
        chunk is stored.

    EndOfUncompressedBufferPlus1 - Supplies a pointer to the next byte
        following the end of the uncompressed buffer.  This is supplied
        instead of the size in bytes because our caller and ourselves
        test against the pointer and by passing the pointer we get to
        skip the code to compute it each time.

    ZivString - Supplies a pointer to the Ziv in the uncompressed buffer.
        The Ziv is the string we want to try and find a match for.

    MatchedString - Receives a pointer to where in the uncompressed
        buffer that the ziv matched.

Return Value:

    Returns the length of the match if the match is greater than three
    characters otherwise return 0.

--*/

{
    ULONG i;
    ULONG BestMatchedLength;
    PUCHAR q;

    //
    //  First check if the Ziv is within two bytes of the end of
    //  the uncompressed buffer, if so then we can't match
    //  three or more characters
    //

    if (ZivString + 3 > EndOfUncompressedBufferPlus1) { return 0; }

    BestMatchedLength = 0;

    for (q = Maximum(UncompressedBuffer, ZivString-4095+1); q < ZivString; q += 1) {

        i = 0;

        while ((i < 18)

                 &&

               (ZivString + i < EndOfUncompressedBufferPlus1)

                 &&

               (ZivString[i] == q[i])) {

            i++;
        }

        if (i >= BestMatchedLength) {

            BestMatchedLength = i;
            *MatchedString = q;
        }
    }

    if (BestMatchedLength < 3) {

        return 0;

    } else {

        return BestMatchedLength;
    }
}
Exemple #29
0
/*
=======================================================================================================================================
ReadNumber
=======================================================================================================================================
*/
qboolean ReadNumber(source_t *source, fielddef_t *fd, void *p) {
	token_t token;
	int negative = qfalse;
	long int intval, intmin = 0, intmax = 0;
	double floatval;

	if (!PC_ExpectAnyToken(source, &token)) {
		return 0;
	}
	// check for minus sign
	if (token.type == TT_PUNCTUATION) {
		if (fd->type & FT_UNSIGNED) {
			SourceError(source, "expected unsigned value, found %s", token.string);
			return 0;
		}
		// if not a minus sign
		if (strcmp(token.string, "-")) {
			SourceError(source, "unexpected punctuation %s", token.string);
			return 0;
		}

		negative = qtrue;
		// read the number
		if (!PC_ExpectAnyToken(source, &token)) {
			return 0;
		}
	}
	// check if it is a number
	if (token.type != TT_NUMBER) {
		SourceError(source, "expected number, found %s", token.string);
		return 0;
	}
	// check for a float value
	if (token.subtype & TT_FLOAT) {
		if ((fd->type & FT_TYPE) != FT_FLOAT) {
			SourceError(source, "unexpected float");
			return 0;
		}

		floatval = token.floatvalue;

		if (negative) {
			floatval = -floatval;
		}

		if (fd->type & FT_BOUNDED) {
			if (floatval < fd->floatmin || floatval > fd->floatmax) {
				SourceError(source, "float out of range [%f, %f]", fd->floatmin, fd->floatmax);
				return 0;
			}
		}

		*(float *)p = (float)floatval;
		return 1;
	}

	intval = token.intvalue;

	if (negative) {
		intval = -intval;
	}
	// check bounds
	if ((fd->type & FT_TYPE) == FT_CHAR) {
		if (fd->type & FT_UNSIGNED) {
			intmin = 0;
			intmax = 255;
		} else {
			intmin = -128;
			intmax = 127;
		}
	}

	if ((fd->type & FT_TYPE) == FT_INT) {
		if (fd->type & FT_UNSIGNED) {
			intmin = 0;
			intmax = 65535;
		} else {
			intmin = -32768;
			intmax = 32767;
		}
	}

	if ((fd->type & FT_TYPE) == FT_CHAR || (fd->type & FT_TYPE) == FT_INT) {
		if (fd->type & FT_BOUNDED) {
			intmin = Maximum(intmin, fd->floatmin);
			intmax = Minimum(intmax, fd->floatmax);
		}

		if (intval < intmin || intval > intmax) {
			SourceError(source, "value %ld out of range [%ld, %ld]", intval, intmin, intmax);
			return 0;
		}
	} else if ((fd->type & FT_TYPE) == FT_FLOAT) {
		if (fd->type & FT_BOUNDED) {
			if (intval < fd->floatmin || intval > fd->floatmax) {
				SourceError(source, "value %ld out of range [%f, %f]", intval, fd->floatmin, fd->floatmax);
				return 0;
			}
		}
	}
	// store the value
	if ((fd->type & FT_TYPE) == FT_CHAR) {
		if (fd->type & FT_UNSIGNED) {
			*(unsigned char *)p = (unsigned char)intval;
		} else {
			*(char *)p = (char)intval;
		}
	} else if ((fd->type & FT_TYPE) == FT_INT) {
		if (fd->type & FT_UNSIGNED) {
			*(unsigned int *)p = (unsigned int)intval;
		} else {
			*(int *)p = (int)intval;
		}
	} else if ((fd->type & FT_TYPE) == FT_FLOAT) {
		*(float *)p = (float)intval;
	}

	return 1;
}
Exemple #30
0
void FloatBuffer::Normalize(float M, float MAX) {
	Multiply( M / (MAX < 0 ? Maximum() : MAX) );
}