Do not cast to float where usual arithmetic conversions obviously

convert the cast's result to double.  Such casts are ugly and may lose
precision.
This commit is contained in:
Markus Armbruster 2006-05-06 08:26:31 +00:00
parent 802f69b039
commit 7a99405942
14 changed files with 35 additions and 35 deletions

View file

@ -99,7 +99,7 @@ coll(void)
xyas(x, y, player->cnum), cname(loan.l_lonee));
return RET_FAIL;
}
pay = dchr[sect.sct_type].d_value * ((float)sect.sct_effic + 100.0);
pay = dchr[sect.sct_type].d_value * (sect.sct_effic + 100.0);
for (i = 0; ichr[i].i_name; i++) {
if (ichr[i].i_value == 0 || ichr[i].i_uid == I_NONE)
continue;

View file

@ -135,7 +135,7 @@ enli(void)
natp->nat_reserve -= totalmil;
putnat(natp);
}
if ((player->btused += roundavg((float)totalmil * 0.02)) > 0)
if ((player->btused += roundavg(totalmil * 0.02)) > 0)
pr("Paperwork at recruiting stations ... %d\n", player->btused);
return RET_OK;
}

View file

@ -179,7 +179,7 @@ fuel(void)
fueled = 1;
if ((pet_amt * 5) >= move_amt) {
extra = ((float)move_amt / 5.0) - (move_amt / 5);
extra = move_amt / 5.0 - move_amt / 5;
if (extra > 0.0)
sect.sct_item[I_PETROL]
= MAX((pet_amt - move_amt / 5) - 1, 0);
@ -189,7 +189,7 @@ fuel(void)
} else {
sect.sct_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = ((float)move_amt / 50.0) - (move_amt / 50);
extra = move_amt / 50.0 - move_amt / 50;
sect.sct_item[I_OIL] = MAX(oil_amt - move_amt / 50, 0);
if (extra > 0.0)
sect.sct_item[I_OIL]
@ -255,7 +255,7 @@ fuel(void)
fueled = 1;
if ((pet_amt * 5) >= move_amt) {
extra = ((float)move_amt / 5.0) - (move_amt / 5);
extra = move_amt / 5.0 - move_amt / 5;
if (extra > 0.0)
item2.ship.shp_item[I_PETROL]
= MAX((pet_amt - move_amt / 5) - 1, 0);
@ -265,7 +265,7 @@ fuel(void)
} else {
item2.ship.shp_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = ((float)move_amt / 50.0) - (move_amt / 50);
extra = move_amt / 50.0 - move_amt / 50;
item2.ship.shp_item[I_OIL]
= MAX(oil_amt - (move_amt / 50), 0);
if (extra > 0.0)
@ -340,7 +340,7 @@ fuel(void)
fueled = 1;
if ((pet_amt * 5) >= move_amt) {
extra = ((float)move_amt / 5.0) - (move_amt / 5);
extra = move_amt / 5.0 - move_amt / 5;
if (extra > 0.0)
sect.sct_item[I_PETROL]
= MAX((pet_amt - move_amt / 5) - 1, 0);
@ -350,7 +350,7 @@ fuel(void)
} else {
sect.sct_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = ((float)move_amt / 50.0) - (move_amt / 50);
extra = move_amt / 50.0 - move_amt / 50;
sect.sct_item[I_OIL] = MAX(oil_amt - move_amt / 50, 0);
if (extra > 0.0)
sect.sct_item[I_OIL]
@ -417,7 +417,7 @@ fuel(void)
fueled = 1;
if ((pet_amt * 5) >= move_amt) {
extra = ((float)move_amt / 5.0) - (move_amt / 5);
extra = move_amt / 5.0 - move_amt / 5;
if (extra > 0.0)
item2.land.lnd_item[I_PETROL]
= MAX((pet_amt - move_amt / 5) - 1, 0);
@ -427,7 +427,7 @@ fuel(void)
} else {
item2.land.lnd_item[I_PETROL] = 0;
move_amt -= pet_amt * 5;
extra = ((float)move_amt / 50.0) - (move_amt / 50);
extra = move_amt / 50.0 - move_amt / 50;
item2.land.lnd_item[I_OIL]
= MAX(oil_amt - move_amt / 50, 0);
if (extra > 0.0)

View file

@ -99,14 +99,14 @@ payo(void)
if (dist < trade_1_dist)
cash = 0;
else if (dist < trade_2_dist)
cash = (1.0 + trade_1 * ((float)dist));
cash = 1.0 + trade_1 * dist;
else if (dist < trade_3_dist)
cash = (1.0 + trade_2 * ((float)dist));
cash = 1.0 + trade_2 * dist;
else
cash = (1.0 + trade_3 * ((float)dist));
cash = 1.0 + trade_3 * dist;
cash *= mp->m_cost;
cash *= (((float)ship.shp_effic) / 100.0);
cash *= ship.shp_effic / 100.0;
if (sect.sct_own && (sect.sct_own != ship.shp_own))
cash *= (1.0 + trade_ally_bonus);

View file

@ -171,7 +171,7 @@ scra(void)
continue;
}
if (type == EF_SHIP) {
eff = ((float)item.ship.shp_effic / 100.0);
eff = item.ship.shp_effic / 100.0;
mp = &mchr[(int)item.ship.shp_type];
if (opt_TRADESHIPS) {
if (mp->m_flags & M_TRADE) {
@ -249,7 +249,7 @@ scra(void)
item.ship.shp_own = 0;
putship(item.ship.shp_uid, &item.ship);
} else if (type == EF_LAND) {
eff = ((float)item.land.lnd_effic / 100.0);
eff = item.land.lnd_effic / 100.0;
lp = &lchr[(int)item.land.lnd_type];
pr("%s", prland(&item.land));
for (i = I_NONE + 1; i <= I_MAX; i++) {
@ -317,7 +317,7 @@ scra(void)
item.land.lnd_own = 0;
putland(item.land.lnd_uid, &item.land);
} else {
eff = ((float)item.land.lnd_effic / 100.0);
eff = item.land.lnd_effic / 100.0;
pp = &plchr[(int)item.plane.pln_type];
pr("%s", prplane(&item.plane));
sect.sct_item[I_LCM] += pp->pl_lcm * 2 / 3 * eff;

View file

@ -204,13 +204,13 @@ scuttle_tradeship(struct shpstr *sp, int interactive)
if (dist < trade_1_dist)
cash = 0;
else if (dist < trade_2_dist)
cash = (1.0 + trade_1 * ((float)dist));
cash = 1.0 + trade_1 * dist;
else if (dist < trade_3_dist)
cash = (1.0 + trade_2 * ((float)dist));
cash = 1.0 + trade_2 * dist;
else
cash = (1.0 + trade_3 * ((float)dist));
cash = 1.0 + trade_3 * dist;
cash *= mp->m_cost;
cash *= (((float)sp->shp_effic) / 100.0);
cash *= sp->shp_effic / 100.0;
if (sect.sct_own != sp->shp_own) {
ally_cash = cash * trade_ally_cut;

View file

@ -265,7 +265,7 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
pln_identchance(pp, shp_hardtarget(targ), EF_SHIP))
continue;
pingrange = MAX(targ->shp_visib, 10) * range / 10;
vrange = ((float)pingrange) * ((float)pp->pln_effic / 200.0);
vrange = pingrange * (pp->pln_effic / 200.0);
dist = mapdist(targ->shp_x, targ->shp_y, x, y);
pingrange = (MAX(pingrange, 2) * targ->shp_effic);
pingrange = roundavg(pingrange / 100.0);