If fixed-length row sizes would result in significant wasted space at the end of the rows, it makes sense to implement a multidimensional array as an explicit ragged array, sizing each row to fit (Ragged Arrays, page 90 (7th ed.) or 102 (8th ed.)).
Examples of such circumstances include upper or lower triangular matrices, or storing a text file in a matrix (the rows would have to be sized to contain the longest line, which wastes space at the end of the rows for lines shorter than the longest).
double
or float
to represent money?
A floating-point number is incapable of exactly representing some decimal numbers, such as 0.01 (Floating-Point Types, page 40 (7th ed.) or 42 (8th ed.)).
This page last modified on 31 March 2008. |