本文整理汇总了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");
}
示例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;
}
示例3:
Fixed Fixed::operator--(int)
{
Fixed res;
res.setRawBits(getRawBits());
--_raw;
return (res);
}
示例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();
}
示例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);
}
示例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);
}
}
示例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);
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例12:
bool Fixed::operator>(Fixed const &rhs)
{
if (this->toFloat() > rhs.toFloat())
return true;
else
return false;
}
示例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();
}
示例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
}
示例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;
}