Skip to content

Odd behaviour with floats & printf #16

Description

@Its-Kenta

I've encountered an odd behaviour with floats and printf where the output returned is not the value you've provided:
We have the following code:

import "std.csp";

fn main(): i32 {
    using std::io;

    macro PI { 3.14159265358979323846 }
    let pi: f32 = 1.2;
    let num: i32 = 55;

    printf("%i\n", num);
    printf("%f\n", PI!);
    printf("%f\n", pi);
    <- 0;
}

The output is:

55
3.0000000000
1.0000000000

Does CSpydr not use the same formatting rule as C? Is there something done wrong in this example or there is a deeper underlying problem causing this? As you can see, the integer is printed out fine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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