float format in JBOX_TRACEVALUES

This forum is for developers of Rack Extensions to discuss the RE SDK, share code, and offer tips to other developers.
User avatar
Murf
RE Developer
Posts: 670
Joined: 21 Jun 2019
Location: Brisbane, Australia

Post 15 Jul 2023

Hi all.
Is their any way to format floats in JBOX_TRACEVALUES so they appear as:
7.1066905e-05

as opposed to:
0.000007
Thanks,
Murf.

User avatar
Enlightenspeed
RE Developer
Posts: 1111
Joined: 03 Jan 2019

Post 19 Sep 2023

Murf wrote:
15 Jul 2023
Hi all.
Is their any way to format floats in JBOX_TRACEVALUES so they appear as:
7.1066905e-05

as opposed to:
0.000007
Thanks,
Murf.
Sorry for the long time in responding to this. I have to say that it looks to me that you are introducing floating point inaccuracies by doing it this way, and that you are best off having the correct format at the point of calculation. Can you tell me more about the application, and also whether the intention is to use 32-bit or 64-bit floats, as the example looks very 32 and thus my assumption above.

Cheers,
Brian

User avatar
Murf
RE Developer
Posts: 670
Joined: 21 Jun 2019
Location: Brisbane, Australia

Post 19 Sep 2023

Enlightenspeed wrote:
19 Sep 2023
Murf wrote:
15 Jul 2023
Hi all.
Is their any way to format floats in JBOX_TRACEVALUES so they appear as:
7.1066905e-05

as opposed to:
0.000007
Thanks,
Murf.
Sorry for the long time in responding to this. I have to say that it looks to me that you are introducing floating point inaccuracies by doing it this way, and that you are best off having the correct format at the point of calculation. Can you tell me more about the application, and also whether the intention is to use 32-bit or 64-bit floats, as the example looks very 32 and thus my assumption above.

Cheers,
Brian
Hi Brian, I am using 64bit floats but this is just for troubleshooting purposes, no risk of lost accuracy in calculations.
Murf

User avatar
Enlightenspeed
RE Developer
Posts: 1111
Joined: 03 Jan 2019

Post 20 Sep 2023

Murf wrote:
19 Sep 2023
Hi Brian, I am using 64bit floats but this is just for troubleshooting purposes, no risk of lost accuracy in calculations.
Murf
Ok, well, looking at the SDK we are allowed the following args in JBOX_TRACEVALUES:

const char[] iFile,
TJBox_Int32 iLine,
const char[] iTemplate,
TJBox_Value[] iValues,
TJBox_Int32 iValueCount

A TJBox_Value is an 8-bit Int, so that won't be any use and neither will the Int32's.
So, the obvious choice is to use the 2nd string iTemplate, and set it up with a debug macro method that does the string formatting and returns to a non-local var, and keep that var/s in a debug macro (My own local builds tend to have about 60 or more of these!) You should then be able to pass it into TraceValues.

If you want to use a better string library than the standard C++ stuff, then remember it needs to get commented, or otherwise removed before universal builds.

Hope this is of some use to you,

Cheers,
Brian

User avatar
pongasoft
RE Developer
Posts: 484
Joined: 21 Apr 2016
Location: Las Vegas

Post 20 Sep 2023

You can always check my small open source project: https://github.com/pongasoft/re-logging

User avatar
Murf
RE Developer
Posts: 670
Joined: 21 Jun 2019
Location: Brisbane, Australia

Post 28 Sep 2023

Thanks guys

  • Information
  • Who is online

    Users browsing this forum: CommonCrawl [Bot] and 0 guests