C float assignment from literal
问题 While reading part of a book about 3D graphics I came across the following assignment: const float vertexPositions[] = { 0.75f, 0.75f, 0.0f, 1.0f, 0.75f, -0.75f, 0.0f, 1.0f, -0.75f, -0.75f, 0.0f, 1.0f, }; Why is the f suffix necessary? Can the type of the literals not be determined from the type of the variable? I believe that without the f float literals are interpreted as doubles, but why when the array is clearly of type float? 回答1: The float array initialization in your example is fine in