Dynamics AX 2012: "Precision lost" warning message

Dynamics AX 2012: "Precision lost" warning message

MCP · Azure DevOpsYour delivery board, readable by an agentMCP · DataverseOne consent, and the data layer opensMCP · Dynamics 365 F&OConnecting F&O to an agent Microsoft hasn’t documented
Archive recovery note: the supplied Blogspot backup did not contain a separate saved page for this older entry. The text available in its archive/listing capture has been preserved and flagged for a later completeness check.
This post is copied from  Peter Villadsen    blog and I thought to share it on my blog too. It really helped me a lot. A question came up at today's webinar where a developer had a (presumably legitimate) reason to cast a real value into an integer value. The X++ language does not allow explicit casting (there's no support for it in the language), but the compiler will do its best to satisfy the user and do the conversion on its own. In this case, however, it issues a warning message, lest this is not what the user wanted. One solution is to use the anytype type to hold the vaue for conversion and then using the any2int function, as shown below: static   void  Job47(Args _args)  { real r =  3.13 ; int  i = r;       // Warning is issued here  anytype a; a = r;           // Assign to an anytype variable...  i = any2int(a);  // ... and back into an int  print r; ...
Previous article← Code for Traverse between Tables and all the fields
Discussion

Ask a question or leave feedback

This is a review interaction. The WordPress version will store, thread and moderate comments.

Thanks — submitted for moderation in this review.
Search the whole site · Ctrl/⌘ + K