Viewing Issue Simple Details Jump to Notes ] Wiki ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000103 [DCSS] Source Cleanup minor have not tried 2009-11-30 11:34 2013-04-08 18:43
Reporter rob View Status public  
Assigned To KiloByte
Priority normal Resolution done  
Status resolved   Product Branch
Summary 0000103: make fractional factors explicit
Description Add a fractional number type, something like

  struct frac { int nom; int denom };

possibly templated over the contained type,
that supports multiplication by ints and
different kinds of rounding. The denominator
would likely be constant, so one could make
that a template parameter, too.

div_rand_round(monster->speed * you.time_taken, 10)
  would become
rand_round(you.time_taken * frac(monster->speed, 10))
  or even
rand_round(you.time_taken * monster->speed)
  after changing monster::speed to be of type frac.

div_round_up(level * 3, 4);
  would become
ceil(level * frac(3,4));

ps *= 15; ps /= 10;
  would become
ps = floor(ps * frac(15, 10));

Of course, making this clean up the source requires making these changes, not just implementing the type.
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
mumra (developer)
2013-04-08 18:35

I don't like the idea of this: huge amount of work for a very small gain. In fact the last example becomes more code not less. Additionally, code templates and operator overloading have a tendency to obfuscate what is actually going on, whereas div_rand_round is a very easy function to understand. Should we close?
KiloByte (manager)
2013-04-08 18:43

+1 to closing. Oops, seems like I've accidentally hit the "close" button rather than "comment", my bad :p

- Issue History
Date Modified Username Field Change
2009-11-30 11:34 rob New Issue
2013-04-08 18:35 mumra Note Added: 0022186
2013-04-08 18:43 KiloByte Note Added: 0022187
2013-04-08 18:43 KiloByte Status new => resolved
2013-04-08 18:43 KiloByte Fixed in Branch => 0.13 development branch
2013-04-08 18:43 KiloByte Resolution open => done
2013-04-08 18:43 KiloByte Assigned To => KiloByte

Mantis 1.1.8[^]
Copyright © 2000 - 2009 Mantis Group
Powered by Mantis Bugtracker