An effective computational method based on a conven- tional modal-expansion approach is presented for solving the problem of diffraction by a deep grating. The groove depth can be the same as or a little more than the grating period. The material can be a perfect conductor, a dielectric, or a metal. The method is based on Yasuura's modal expansion, which is known as a least-squares boundary residual method or a modified Rayleigh method. The feature of the present method is that: (1) The semi-infinite region U over the grating sur- face is divided into an upper half plane U0 and a groove region UG by a fictitious boundary (a horizontal line); (2) The latter is further di- vided into shallow horizontal layers U1 ,U 2, ··· ,U Q again by fictitious boundaries; (3) An approximate solution in U0 is defined in a usual manner, i.e., a finite summation of up-going Floquet modal functions with unknown coefficients, while the solutions in Uq (q =1 , 2, ··· ,Q ) include not only the up-going but also the down-going modal functions; (4) If the grating is made of a dielectric or a metal, the semi-infinite region L below the surface is partitioned similarly into L0 ,L 1, ··· ,L Q, and approximate solutions are defined in each region; (5) A huge-sized least squares problem that appears in finding the modal coefficients is solved by the QR decomposition accompanied by sequential accu- mulation. The method of solution for a grating made of a perfect conductor is described in the text. The method for dielectric gratings can be found in an appendix. Numerical examples include the results for perfectly conducting and dielectric gratings.