Hello! Tell me, are there MI instructions for performing operations on numbers in decimal format? These instructions are intended to be used from a C program.
Announcement
Collapse
No announcement yet.
MI instructions for decimal operations
Collapse
X
-
Yes, Scott, I can explain. The thing is, I actually need to work with decimal from a C++ program, not C. The _DecimalT class template, located in bcd.h, of course provides the full functionality for working with decimal. However, compared to C and RPG, operations with it are about 10 times slower (it measures the speed of a division operation). So I thought that you can write your own class to work with decimal, but use MI instructions to perform operations, and not call __pdiv and other similar functions, as is done in the _DecimalT template.
Comment
-
You can use the decimal functions in decimal.h in a C++ program.
Code:#include <iostream> #include <decimal.h> int main() { decimal(15,5) x; x = 5; x += .2; std::cout << x; return 0; }
Comment
-
I see.
Unfortunately, I'm not aware of a way to use MI functions. Maybe you could write a set of C or RPG functions, then wrap those with a C++ class? Just a thought.
Aside from that, I'm not sure what to suggest.
Comment
-
It would be great to use C++ wrappers over C or RPG functions. But the problem is that the concrete type decimal is a compile time property. And since I am writing a library in C++ and it is not known in advance which specific type of decimal the user wants to use, then using the wrapper looks impossible for me.
-
-
-
-
It has been a very, very, very long time since I've written an MI program -- it may have changed completely since then. But, I see there is an example in IBM Docs
Comment
Comment