This is where you talk about the NXJ software itself, installation issues, and programming talk.
Moderators: roger, 99jonathan, imaqine
by DAEdwards » Sun Nov 18, 2012 10:49 pm
How do I format doubles (and ints) into strings with format control ( largely for RConsole tracing purposes) ? I'm a really new user to Java and LeJos but know C++ well. I'm looking for the equivalent of sprintf(). From what I can tell String.format is not implemented on the leJOS ? Am I stuck doing my own formating ?
The main needs are
- limit the decimal places
- perhaps fixed length strings (to help column alignment of data)
- possible commas for 1000's etc
Thanks
-
DAEdwards
- New User
-
- Posts: 2
- Joined: Sun Nov 18, 2012 10:39 pm
by skoehler » Mon Nov 19, 2012 12:42 am
What you are looking for, has not been implemented for leJOS yet.
If you're looking for a fixed number of decimal places without the scientific notation, you can write your own formatting of values in a certain range by casting to long after multiplying by 10 to the number of decimal places you want to have.
-
skoehler
- leJOS Team Member
-
- Posts: 1114
- Joined: Thu Oct 30, 2008 4:54 pm
by DAEdwards » Mon Nov 19, 2012 1:46 am
Thanks. NO problem. Just wanted to be certain I wasn't missing anything obvious since I was new to both leJos and Java.
Thanks for the suggestion on how to do it.
-
DAEdwards
- New User
-
- Posts: 2
- Joined: Sun Nov 18, 2012 10:39 pm
Return to NXJ Software
Who is online
Users browsing this forum: No registered users and 2 guests