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

round decimals to 2 places #28

Closed
echeran opened this issue Jul 15, 2016 · 3 comments
Closed

round decimals to 2 places #28

echeran opened this issue Jul 15, 2016 · 3 comments
Labels

Comments

@echeran
Copy link
Collaborator

echeran commented Jul 15, 2016

When printing the turtle position in the REPL, we get full precision of the floating point. We only need 2 decimal places at most.

@galbacarys
Copy link

Hey, is this referring to the output you get after each movement command? Or is there some other print command I'm missing? I'd like to take this on.

@jeisses
Copy link
Contributor

jeisses commented Aug 3, 2017

@galbacarys This probably refers to the string representation of the turtle. After each movement command the Turtle record is returned, thus printed in the REPL. There are some functions that determine the format of this string

@echeran
Copy link
Collaborator Author

echeran commented Aug 3, 2017

Yes, @jeisses is right. Keep in mind that there's a difference between println/print (printing meant for humans to read) and prn/pr (printing in such a way that the REPL's reader can read them). The REPL uses prn to print return vals.

A custom prn has already been implemented / extended for Turtle values for CLJ and for CLJS. So for the purposes here, we just need to work within the pr-str-turtle fn to customize how the values for :x, :y, and :angle get turned into a string. The math libs in Java vs. JS are probably different, so we'll need reader conditionals.

On second thought, I think just one digit after the decimal point is enough.

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

No branches or pull requests

3 participants