A sedimentary rock consisting primarily of calcium carbonate (the mineral, calcite). Limestone is generally formed by accumulation, mostly in place or with only short transport, of the shells of marine animals, but it may also form by direct chemical precipitation from solution in hot springs or caves and, in some instances, in the ocean.