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

PREC1 and PREC2 formatting parameters not functioning correct. #3150

Closed
lshems opened this issue Dec 14, 2015 · 13 comments
Closed

PREC1 and PREC2 formatting parameters not functioning correct. #3150

lshems opened this issue Dec 14, 2015 · 13 comments

Comments

@lshems
Copy link
Contributor

lshems commented Dec 14, 2015

the "PREC1" parameter used to format numbers being printed with1 decimal is working differently. It used to just place a decimal point before the last whole number digit. Now it seems to just give the 1/10 value in the output after the digit, so it is really only a "format" parameter.

value 67, OLD 'PREC1' format output: 6.7, new 'PREC1' format output: 67.0

also, there seem to be some rounding errors. 8.2 is formatted as 8.19 with 'PREC2'

@projectkk2glider
Copy link
Member

Confirmed:

local function run(event)
  lcd.clear()
  lcd.drawNumber(10, 10, 1234, LEFT)
  lcd.drawNumber(10, 20, 1234, PREC1+LEFT)
  lcd.drawNumber(10, 30, 1234, PREC2+LEFT)
  return 0
end

return { run=run }

produces:
snapshot_01

also, there seem to be some rounding errors. 8.2 is formatted as 8.19 with 'PREC2'

That is Lua rounding error when the floating point number is converted to integer. We can't do much about it.

@projectkk2glider
Copy link
Member

Looks like this was a deliberate change done in bab4168. So the question for @bsongis:

  • do we change the documentation to reflect the new funcitonality
  • or we change back the functionality the way it was in 2.0?

I vote for the first option.

@bsongis
Copy link
Member

bsongis commented Dec 14, 2015

I also prefer the first option

@bsongis
Copy link
Member

bsongis commented Dec 14, 2015

The Lua rounding error should be reported in a different issue, perhaps we can do something!

@lshems
Copy link
Contributor Author

lshems commented Dec 15, 2015

the rounding doesn't occur when just shifting the decimal. so for that reason I would prefer the second option. It is only a formatting issue, and num2text does it correct.

@bsongis
Copy link
Member

bsongis commented Dec 15, 2015

Well I have nothing against the 2nd solution, it would be consistent with the firmware itself. Just a little bit more difficult to explain.

@projectkk2glider
Copy link
Member

Yes, the second option would be consistent. For a more elaborate string formatting one can use the Lua string library now.

@lshems
Copy link
Contributor Author

lshems commented Dec 16, 2015

Bertrand,

I am new to all this github stuff.

The issue about PREC1 and PREC2, do i see it correct if the original
behaviour is being restored, that is 30 PREC1 is dislayed as 3.0 ??

How can I see in which nightly it will be updated so I can test??

Thanks for the reply.

Guido

Met vriendelijke groet

Guido ter Horst
+32 499 708000

On Tue, Dec 15, 2015 at 7:07 AM, Bertrand Songis notifications@github.com
wrote:

Well I have nothing against the 2nd solution, it would be consistent with
the firmware itself. Just a little bit more difficult to explain.


Reply to this email directly or view it on GitHub
#3150 (comment).

@bsongis
Copy link
Member

bsongis commented Dec 16, 2015

15 hours, it will be in the nightly builds tomorrow morning!

@lshems
Copy link
Contributor Author

lshems commented Dec 17, 2015

Perfect.

If this is fixed, I have to do some final testing, and then I can release my updated F3K toolset.compatible with 2.0 and 2.1.

:)

@astrohome
Copy link

Any news concerning this bug?

@projectkk2glider
Copy link
Member

It's fixed in 2.1.7

@astrohome
Copy link

@projectkk2glider my bad - I haven't seen that it's closed already.

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

No branches or pull requests

4 participants