Skip to content

Frequency ratio is not constructed correctly from time ratio #140

@pavelkryukov

Description

@pavelkryukov

Describe the bug
Frequency ratio is not constructed correctly from time ratio

To Reproduce

#include "include/SI/frequency.h"

#include <iostream>

int main()
{
    // Creating 1 millisecond
    auto t = SI::milli_seconds_t<double>(1.);

    // 1 beat per 1 millisecond is 1 kHz
    auto f = 1. / t;

    // Expecting to see 1 as f should contain 1 kHz
    std::cout << f.as<SI::kilo_hertz_t>().value() << std::endl;

    return 0;
}

Output: 1e-06

Expected behavior
Expected to see 1 on the screen.

Additional context
Reproduced with g++-10 --std=c++20.
It appears to me that f contains 1 mHz insted of 1 kHz, thus converting to 1 kHz turns to be 1e-06

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions