Skip to content

flt2dec comments and code disagree about the numbers of parts required for formatting #41304

Closed
@froydnj

Description

@froydnj

The comments for flt2dec::to_shortest and other similar functions describe the required size of the &mut [Part] parameters. However, the assertions contained in those functions do not check the size described in the comments:

  • to_shortest_str requires 5 in the comments, but asserts that the size is >= 4;
  • to_exact_fixed_str does the same.

The comments appear to be confused, as the [0.] bit that they are apparently counting as a Part is not; perhaps this is a remnant left over from a previous refactoring.

  • to_shortest_exp_str requires 7 in the comments, but asserts that the size is >= 6;
  • to_exact_exp_str does the same.

The comments suggest that the worst case for the exponent would require 17 bits or more, which seems overly conservative.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions