Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected nf()-formatting #1879

Closed
mcsanta opened this issue Apr 6, 2017 · 3 comments
Closed

Unexpected nf()-formatting #1879

mcsanta opened this issue Apr 6, 2017 · 3 comments
Assignees

Comments

@mcsanta
Copy link

mcsanta commented Apr 6, 2017

Hi,

when using the nf()-function, the number gets formatted regardless of scientific notation. This makes very small or very big numbers indistinguishable.

Consider this example

function setup() { 
    createCanvas(400, 400);
} 

function draw() {
    background(220);

    smallNumber = 3.8944423423433e-14;
    text(smallNumber, 50, 50);
    text(nf(smallNumber, 1, 3), 50, 65);
	
    mediumNumber = 3.8944423423433;
    text(mediumNumber, 50, 100);
    text(nf(mediumNumber, 1, 3), 50, 115);
	
    bigNumber = 3.8944423423433e+50;
    text(bigNumber, 50, 150);
    text(nf(bigNumber, 1, 3), 50, 165);
}

Please let me know if the information provided is sufficient. And since this is my first contribution, I'm also open to general suggestions for improvement.

Best

@lmccart
Copy link
Member

lmccart commented Apr 15, 2017

@mlarghydracept?

@lmccart
Copy link
Member

lmccart commented Apr 19, 2017

after investigating solutions, we've determined there's a significant cost of performance and complexity to the code for a relatively less common use case. as reference, it looks like processing also doesn't support scientific notation in these functions. at this point, we've decided to forgo scientific notation support.

@lmccart lmccart closed this as completed Apr 19, 2017
@mcsanta
Copy link
Author

mcsanta commented Apr 20, 2017

Thanks for the feedback, this makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants