-
Notifications
You must be signed in to change notification settings - Fork 156
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
Display labels and values to ADSREG #51
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,6 +279,15 @@ class HemisphereApplet { | |
return padding; | ||
} | ||
|
||
int digitCount(int n) { | ||
int count = 0; | ||
while (n != 0) { | ||
n /= 10; // n = n/10 | ||
++count; | ||
} | ||
return count; | ||
} | ||
Comment on lines
+282
to
+289
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, by no means a blocker, but I'm of the school of thought where we should avoid imperative-style code as well as potentially infinite loops. My brain is a little fried right now because I've been jumping between PRs all morning, but my instincts are telling me there might be a cleaner and safer way to write this method. I could 100% be wrong and you could have tried a million things, in which case, ignore my dumb butt :p There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's pretty much the canonical way to count digits in C. No int exists that will cause an infinite loop, and log10() is much slower. |
||
|
||
//////////////// Hemisphere-specific graphics methods | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be beneficial to the next person to pull the equation of the first arg out into its own variable with a comment. This way there's less logic inline and less to consider while you're reading it.