当前位置: 首页>>代码示例>>C++>>正文


C++ Fixed类代码示例

本文整理汇总了C++中Fixed的典型用法代码示例。如果您正苦于以下问题:C++ Fixed类的具体用法?C++ Fixed怎么用?C++ Fixed使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Fixed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GTEST_TEST

GTEST_TEST(Fixed, version) {
    Fixed version(1, 0);
    EXPECT_EQ(version.toString(), "1.0");

    Fixed fixed = 3.7;
    EXPECT_EQ(fixed.toString(), "3.7");
}
开发者ID:seirion,项目名称:TrueType,代码行数:7,代码来源:test_fixed.cpp

示例2: IntersectRaySphereX

int IntersectRaySphereX(	const SphereX& sphere,
                            const Vector3X& p,
                            const Vector3X& dir,
                            Fixed* t )
{
    Vector3X raySphere = sphere.origin - p;
    Fixed raySphereLen2 = DotProduct( raySphere, raySphere );
    Fixed sphereR2 = sphere.radius*sphere.radius;

    if (raySphereLen2 < sphereR2) 
    {	
        // Origin is inside the sphere.
        return grinliz::INSIDE;
    } 
    else 
    {
        // Clever idea: what is the rays closest approach to the sphere?
        // see: http://www.devmaster.net/wiki/Ray-sphere_intersection

        Fixed closest = DotProduct(raySphere, dir);
        if (closest < 0) {
            // Then we are pointing away from the sphere (and we know we aren't inside.)
            return grinliz::REJECT;
        }
        Fixed halfCordLen = (sphereR2 - raySphereLen2) / DotProduct(dir, dir) + (closest*closest);
        if ( halfCordLen > 0 ) {
            *t = closest - halfCordLen.Sqrt();
            return grinliz::INTERSECT;
        }
    }
    return grinliz::REJECT;
}
开发者ID:chrisBGithub,项目名称:unflobtactical,代码行数:32,代码来源:fixedgeom.cpp

示例3:

Fixed					Fixed::operator--(int)
{
    Fixed res;

    res.setRawBits(getRawBits());
    --_raw;
    return (res);
}
开发者ID:avallete,项目名称:CPPool,代码行数:8,代码来源:Fixed.class.cpp

示例4: AVisWidget

AVisFixed::AVisFixed(const string& aName, Elem* aMan, MEnv* aEnv): AVisWidget(aName, aMan, aEnv)
{
    SetEType(Type(), AVisWidget::PEType());
    SetParent(Type());
    Fixed* fx = new Fixed(); 
    fx->set_reallocate_redraws(true);
    iWidget = fx;
    iWidget->show();
}
开发者ID:yborisovstc,项目名称:fap2-studio-gtk,代码行数:9,代码来源:desvis.cpp

示例5:

Fixed Fixed::operator*(Fixed const &rhs) {
    Fixed    f;
    int        result;
    
    result = this->_fixe * rhs.getRawBits();
    result += 1 << (this->_fractionalbits - 1);
    result >>= this->_fractionalbits;
    f.setRawBits(result);
    return (f); 
}
开发者ID:mbarbari,项目名称:42_project,代码行数:10,代码来源:Fixed.cpp

示例6: OnUpdated_Y

void AVisDrawing::OnUpdated_Y(int aY)
{
    Allocation alc = iWidget->get_allocation();
    Container* parent = iWidget->get_parent();
    // Y change handles only by Fixed parent
    Fixed* fx = dynamic_cast<Fixed*>(parent);
    if (fx != NULL) {
    fx->move(*iWidget, iX, iY);
    }
}
开发者ID:yborisovstc,项目名称:fap2-studio-gtk,代码行数:10,代码来源:desvis.cpp

示例7: return

Fixed Fixed::operator/(Fixed const &rhs) {
    Fixed    f;
    int        result;

    result = this->_fixe << _fractionalbits;
    result += this->_fixe / 2;
    result /= this->_fixe;

    f.setRawBits(result);
    return (f);
}
开发者ID:mbarbari,项目名称:42_project,代码行数:11,代码来源:Fixed.cpp

示例8: while

void BudgetWindow::RefreshBudgetGrid(void)
{
    fIncomeGrid.MakeEmpty();
    fSpendingGrid.MakeEmpty();

    CppSQLite3Query query = gDatabase.DBQuery("select category,amount,period from "
                                            "budgetlist order by category",
                                            "BudgetWindow::RefreshCategories");
    while(!query.eof())
    {
        BString cat = DeescapeIllegalCharacters(query.getStringField(0));
        Fixed amount;
        amount.SetPremultiplied(query.getInt64Field(1));
        BudgetPeriod period = (BudgetPeriod)query.getIntField(2);

        ReportGrid *grid = (amount.IsPositive()) ? &fIncomeGrid : &fSpendingGrid;

        int32 index = grid->CountItems();
        grid->AddItem();
        grid->SetRowTitle(index, cat.String());

        Fixed f(amount.AbsoluteValue());
        switch(period)
        {
            case BUDGET_QUARTERLY:
            {
                f /= 3;
                Fixed qamt(amount);
                qamt *= 4;
                grid->SetValue(12,index,qamt);
                break;
            }
            case BUDGET_ANNUALLY:
            {
                f /=12;
                grid->SetValue(12,index,amount);
                break;
            }
            default:
            {
                Fixed mamt(f);
                mamt *= 12;
                grid->SetValue(12,index,mamt);
                break;
            }
        }

        for(int32 i=0; i<12; i++)
            grid->SetValue(i,index,f);

        query.nextRow();
    }
}
开发者ID:HaikuArchives,项目名称:CapitalBe,代码行数:53,代码来源:BudgetWindow.cpp

示例9: main

int main(void)
{
    Fixed a;
    Fixed b( a );
    Fixed c;

    c = b;
    std::cout << a.getRawBits() << std::endl;
    std::cout << b.getRawBits() << std::endl;
    std::cout << c.getRawBits() << std::endl;
    return 0;
}
开发者ID:bensisko69,项目名称:projet_42,代码行数:12,代码来源:main.cpp

示例10: main

int main() {
    Fixed n(-10.0);
    Fixed f(-100.0);
    Fixed d(2.0);
    Fixed a(1.5);
    Fixed b(-1.5);
    Fixed c = -a;
    Fixed r = d / (n - f);

    cout << r.to_float() << ' ' << r.num << endl;
    cout << a.num << ' ' << b.num << ' ' << c.num << endl;
    printf("%X %X\n", a.num, b.num);

    return 0;
}
开发者ID:hdhzero,项目名称:octographics,代码行数:15,代码来源:Fixed.cpp

示例11: BRow

void BudgetWindow::RefreshCategories(void)
{
    fCategoryList->Clear();
    fIncomeRow = new BRow();
    fCategoryList->AddRow(fIncomeRow);
    fSpendingRow = new BRow();
    fCategoryList->AddRow(fSpendingRow);
    fIncomeRow->SetField(new BStringField(TRANSLATE("Income")),0);
    fSpendingRow->SetField(new BStringField(TRANSLATE("Spending")),0);

    CppSQLite3Query query = gDatabase.DBQuery("select category,amount,period,isexpense from "
                                            "budgetlist order by category",
                                            "BudgetWindow::RefreshCategories");
    float maxwidth=fCategoryList->StringWidth("Category");
    while(!query.eof())
    {
        BString cat = DeescapeIllegalCharacters(query.getStringField(0));
        Fixed amount;
        amount.SetPremultiplied(query.getInt64Field(1));
        BudgetPeriod period = (BudgetPeriod)query.getIntField(2);

        BRow *row = new BRow();

        if(query.getIntField(3)==0)
            fCategoryList->AddRow(row,fIncomeRow);
        else
            fCategoryList->AddRow(row,fSpendingRow);

        row->SetField(new BStringField(cat.String()),0);

        BString amountstr;
        gDefaultLocale.CurrencyToString(amount.AbsoluteValue(),amountstr);
        amountstr.Truncate(amountstr.FindFirst(gDefaultLocale.CurrencyDecimal()));
        amountstr.RemoveFirst(gDefaultLocale.CurrencySymbol());

        row->SetField(new BStringField(amountstr.String()),1);

        float tempwidth = fCategoryList->StringWidth(cat.String());
        maxwidth = MAX(tempwidth,maxwidth);

        row->SetField(new BStringField(BudgetPeriodToString(period).String()),2);

        query.nextRow();
    }
    fCategoryList->ColumnAt(0)->SetWidth(maxwidth+30);
    fCategoryList->ExpandOrCollapse(fIncomeRow,true);
    fCategoryList->ExpandOrCollapse(fSpendingRow,true);
}
开发者ID:HaikuArchives,项目名称:CapitalBe,代码行数:48,代码来源:BudgetWindow.cpp

示例12:

bool			Fixed::operator>(Fixed const &rhs)
{
    if (this->toFloat() > rhs.toFloat())
        return true;
    else
        return false;
}
开发者ID:bensisko69,项目名称:projet_42,代码行数:7,代码来源:Fixed.cpp

示例13: fixtos

static std::string		fixtos(Fixed f)
{
//	std::cout << __func__ << " (" << __FILE__ << ") - line: " << __LINE__ << std::endl;	//debug
    std::ostringstream ss;

    ss << f.toFloat();
    return ss.str();
}
开发者ID:JeanMax,项目名称:Piscine_CPP,代码行数:8,代码来源:main.cpp

示例14: SetData

void DirectoryData::SetData ( Fixed newData )
{
    m_type = DIRECTORY_TYPE_FIXED;
#ifdef FLOAT_NUMERICS
    m_fixed = newData.DoubleValue();
#elif defined(FIXED64_NUMERICS)
    m_fixed = newData.m_value;
#endif
}
开发者ID:gene9,项目名称:Darwinia-and-Multiwinia-Source-Code,代码行数:9,代码来源:directory.cpp

示例15:

void MapVec2::normalize()
{
    Fixed n = x * x + y * y;

    // Already normalized.
    if (n == Fixed::ONE)
    {
        return;
    }

    n = n.sqrt();

    // zero.
    if (n == Fixed::ZERO)
    {
        return;
    }

    n = Fixed::ONE / n;
    x *= n;
    y *= n;
}
开发者ID:RayRiver,项目名称:LinkWar,代码行数:22,代码来源:MapStructs.cpp


注:本文中的Fixed类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。