News:

  • July 01, 2026, 06:18:54 PM

Login with username, password and session length

Author Topic: FmtReal possible bug  (Read 12865 times)

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
FmtReal possible bug
« on: May 08, 2015, 12:43:48 PM »
I am trying to use a FmtReal(R2,1,0,dec) inside a STRPRINT.
The value in R2 is "2000", the value printed is "2000.000000"
Am I doing something wrong?

Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3833
    • Host Engineering
Re: FmtReal possible bug
« Reply #1 on: May 08, 2015, 01:33:58 PM »
Appears to be a bug - not sure why.  It should do what you are expecting.

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: FmtReal possible bug
« Reply #2 on: May 08, 2015, 01:37:23 PM »
OK.
Thanks!
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: FmtReal possible bug
« Reply #3 on: May 08, 2015, 01:39:15 PM »
Apparently 0 precision translates into something like max precision. I'll look into it. Might not have any choice but to convert to int.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: FmtReal possible bug
« Reply #4 on: May 08, 2015, 02:40:33 PM »
Zero is being treated as no precision specified, i.e., as printf("%f") instead of printf("%*.0f"). Given that ".0" serves a useful purpose for printf, I guess I should change it, although it makes me slightly nervous to do so.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: FmtReal possible bug
« Reply #5 on: May 08, 2015, 02:45:36 PM »
I was only going by the manual (I actually read it :) )

Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: FmtReal possible bug
« Reply #6 on: May 08, 2015, 03:05:04 PM »
I was only going by the manual (I actually read it :) )

'0' is valid...it just meant don't use the precision specifier.

I have now changed it...and instructed DocuMan to reflect accordingly...to using 255 as the 'don't use precision value'. Zero will do what it was actually intended to do. Sorry for the oops, and thanks for the heads up.

"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Re: FmtReal possible bug
« Reply #7 on: May 17, 2015, 09:05:17 PM »
After reading this thread, I had to try it out in the simulator. Yep it's the same. So I also tried 255 for the precision in FmtReal per help file, well any value over 102 caused simulator to crash.

I just want to let you know in-case it could be a problem in the do-more itself.

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: FmtReal possible bug
« Reply #8 on: May 18, 2015, 08:24:55 AM »
I also tried 255 for the precision in FmtReal per help file, well any value over 102 caused simulator to crash.

If I place 255 in an actual CPU, I get the result that I expected to get from a 0 (Zero); there were no zeroes after the decimal...
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: FmtReal possible bug
« Reply #9 on: May 18, 2015, 10:54:00 AM »
All of the internal token buffers were 100 bytes, which under normal circumstances is about 90 bytes longer than needed. With 255 characters following the decimal, she go boom.

I've fixed both issues.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO