Mysterious bug loosing decimal places in variant assignment

gerdhuebnergerdhuebner Member Posts: 155
When working on a general data transfer tool, I encountered a very mysterious bug. Consider the following codeunit:
OBJECT Codeunit 79438 Mysterious Bug
{
  OBJECT-PROPERTIES
  {
    Date=29.08.09;
    Time=09:03:48;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    OnRun=BEGIN
            recRef.OPEN(DATABASE::Item);
            fldRef := recRef.FIELD(18);  // "Unit Price"

            fldRef.VALUE := 1.23456;
            varVar := fldRef.VALUE;      // varVar is DataType Variant

            MESSAGE('The fldRef.VALUE is %1, but the varVar value is %2!',fldRef.VALUE,varVar);
          END;

  }
  CODE
  {
    VAR
      recRef@1000000002 : RecordRef;
      fldRef@1000000003 : FieldRef;
      varVar@1000000001 : Variant;

    BEGIN
    END.
  }
}
If you run this codeunit, the message will give you 1.2346 instead of 1.23456 for the value of the variant variable. It seems to be that during the assignment of the varVar variable the result is rounded to 4 decimal places, regardless of the original value.
The bug only occurs when you assign a fldRef.VALUE of type decimal to a variant variable. Assignment of a decimal variable to a variant variable is working properly.

It looks like the bug has already been reported as "problem" in 2005 here:
http://www.mibuso.com/forum/viewtopic.php?f=14&t=5069

Comments

  • krikikriki Member, Moderator Posts: 9,110
    I encountered this bug in NAV3.60. In 3.70 is was solved. I don't know if the bug was re-introduced in later versions.

    Which version (and build) are you using?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • gerdhuebnergerdhuebner Member Posts: 155
    Well, I tested the above codeunit in 3.70A, 3.70B, 4.0 SP3, 5.0 SP1, NAV 2009 with exactly the same result.
  • krikikriki Member, Moderator Posts: 9,110
    Ok, I missed a part of your post.
    I had the problem with a decimal in 3.60 that was solved in 3.70.
    Seems they never fixed it for variants.

    Better report it to Microsoft!
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.