Greetings, all!
I used to know this answer, but I haven't worried about it in so long I can't remember.
Our data is masked with extra decimal positions. For example, 1.35 may be masked with 2 decimal places and stored as 135. When using this data for output, which is better performance-wise - OCONV or dividing by 100?
Thank you!
------------------------------
Brian Paige
------------------------------
Brian,
Both are very fast, fractional milliseconds, and while the div is faster I feel the OCONV handles invalid data better than the mathematical expression .
OCONV will not produce a runtime error if the data is non-numeric, and returns the value passed in, where the invalid DIV returns zero
i.e.
CRT OCONV("MIKE", "MD2")
produces
MIKE
Where:
CRT "MIKE" / 100
produces
Program "yourprogramname": Line 18, Nonnumeric data when numeric required. Zero used.
0
So, it also depends where you plan on using it, and how you would want to deal with non-numeric data.
Note that both methods will set the status, so you can check if there were issues after the fact with STATUS() if this is being done in your basic program.
------------------------------
Mike Rajkowski
MultiValue Product Evangelist
Rocket Internal - All Brands
DENVER CO US
------------------------------
Brian,
Both are very fast, fractional milliseconds, and while the div is faster I feel the OCONV handles invalid data better than the mathematical expression .
OCONV will not produce a runtime error if the data is non-numeric, and returns the value passed in, where the invalid DIV returns zero
i.e.
CRT OCONV("MIKE", "MD2")
produces
MIKE
Where:
CRT "MIKE" / 100
produces
Program "yourprogramname": Line 18, Nonnumeric data when numeric required. Zero used.
0
So, it also depends where you plan on using it, and how you would want to deal with non-numeric data.
Note that both methods will set the status, so you can check if there were issues after the fact with STATUS() if this is being done in your basic program.
------------------------------
Mike Rajkowski
MultiValue Product Evangelist
Rocket Internal - All Brands
DENVER CO US
------------------------------
Thanks, Mike! That helps a lot!!
Brian
Greetings, all!
I used to know this answer, but I haven't worried about it in so long I can't remember.
Our data is masked with extra decimal positions. For example, 1.35 may be masked with 2 decimal places and stored as 135. When using this data for output, which is better performance-wise - OCONV or dividing by 100?
Thank you!
------------------------------
Brian Paige
------------------------------
Since you asked, division is faster. I can set point size, but not font, so select a fixed width font for viewing.
CPU.......
Iteration..... (uSec) per Standard..
Test Category...... Loop Core...................... Iteration. Deviation. *
249 OCONV 135 MD2 0.267 0.0171
250 Division 135/100 0.009 0.0002
2 records listed.
------------------------------
Mark A Baldridge
Principal Consultant
Thought Mirror
Nacogdoches, Texas United States
------------------------------