Error of comparison while trying to round like Excel

I have two different but related issues. First: my LabVIEW application is not passing validation of my client because the results in LabVIEW are not exactly the same as those that my customer buy when using MS Excel. The problem is with rounding: LabVIEW and Excel round numbers differently and (unfortunately) I have to round up the numbers in the way that Excel.

Because I need to round up after the comma, I started using a beautiful VI I found here at ni.com called 'DecimalRoundingLV8.5vi'. However, due to the difference between LabVIEW and Excel, I can't use this VI as it is. For example, rounded to the third place after the comma:

The number to round LABVIEW EXCEL
0.0045 0.0040 0,0050

So, my first question is this one, I need to round like Excel... However, the solution I implemented raised an odd question, and I don't know if I see a bug in LabVIEW.

I changed the decimal rounded VI. Here is a picture of the code and I also enclose it:

First of all, if the number is negative I change into a positive for rounding. In the end, I return the sign.

Like the original VI, I multiply the number to round up times 10 ^ x, where x is the place after the decimal point, I would like to turn to, I'm rounding and then dividing by 10 ^ x.

However, I also multiply the number of round 10 ^(x+1) time and divide the result by 10 to get the unit as the reminder and to evaluate this number. If the number is less than 5, I tour as usual; If not, round towards + infinity.

So far, so good and everything seems to be fantastic. But when I tested this code I found the following bizarre scenario. For example, rounded to the third place after the comma:

The number to round LABVIEW EXCEL
0.0855 0.0860 0.0860
0.0856 0.0860 0.0860
0,0857 0.0860 0.0860
0.0858 0.0860 0.0860
0.0859 0.0860 0.0860
0.0860 0.0860 0.0860
0.0861 0.0860 0.0860
0.0862 0.0860 0.0860
0.0863 0.0860 0.0860
0.0864 0.0860 0.0860
0,0865 0.0860 0.0870
0,0866 0.0870 0.0870
0,0867 0.0870 0.0870
0,0868 0.0870 0.0870
0.0869 0.0870 0.0870
0.0870 0.0870 0.0870
0.0871 0.0870 0.0870
0.0872 0.0870 0.0870
0.0873 0.0870 0.0870
0,0874 0.0870 0.0870
0,0875 0.0880 0.0880

Note When the flare 0,0865. LabVIEW is wrong! However, LabVIEW was not wrong for 0.0855 or 0,0875. When I ran the code using the highlight feature, it turns out that the problem was the comparison function. It is said literally than 5<5 is="">.

I tested in LabVIEW 8.2 and LabVIEW 12. I use Windows XP SP3.

These numbers are not the only cases with this weird behavior. Other numbers are 0.1425, 0.1725 0.1745 and more. I don't see a drawing (or a reason!)

Can someone please test my code and report if you met the same behavior?

Enrique,

It is a fundamental issue with the help of the binary representation over for numbers.  Event that you post and think that numbers like decimal representations, the computer stores in a binary format.  As 0.0045 or 0.004 number can be represented in binary format used by LabVIEW.  Place a digital control on a new VI. Set the display format to show ~ 20 significant digits.  Type in 0.004 or 0.0045 hit and hit enter.

0.0045-> 0.0044999999999999996600

The correct rounding for this value is 0.004.  Of course typing 0.004 gives 0.004000000000000000080.

I don't have Excel so I don't know what it does, but it will have the same problem with approximate representations of numbers.

There are a lot of posts on the Forums about number representation.

In addition, the reason that the exact equality comparisons on the non-entier data types should be avoided or used with caution.

Lynn

Tags: NI Software

Similar Questions

  • 404 not found error was encountered while trying to use an ErrorDocument directive to manage demand

    When I try to go to my site, I get a blank screen and this message:

    Method not implemented

    GET to / not supported.

    Additionally, a 404 not found error was encountered while trying to use an ErrorDocument directive to manage demand.

    Can someone help me fix this bug, please? Thank you!

    This problem may be caused by corrupted cookies or cookies that are blocked (check the permissions on the subject: permissions page).

    Clear the cache and cookies only from Web sites that are causing problems.

    "Clear the Cache":

    • Firefox > Preferences > advanced > network > content caching Web: 'clear now '.

    'Delete Cookies' sites causing problems:

    • Firefox > Preferences > privacy > "Use the custom settings for history" > Cookies: "show the Cookies".

    Please upgrade to the current version of Firefox 30.

    • Firefox > topic

    The version of Firefox you are currently running is no longer supported with security updates.

    • It is important to update Firefox and Add-ons to the latest version to get all security patches.

    You can find the full version of the current version of Firefox 30.0 in all languages and for all systems operating here:

  • Error code 0000064c while trying to update

    Error code 0000064c while trying to update (dt000) on vista. any help much appreciated.

    Thanx
    Josh

    Hello

    Please provide information on the updates are to receive messages in your windows under Windows Updates. Then you can check if these updates are lying to your windows or not from http://support.microsoft.com.

    For now, try the following steps:

    1. Open the Windows services control panel (Control Panerl--> administrative tools)
    2. Stop the Service of Cryptographic Service, Windows Installer of Module Background Intelligent Transfer and services of Windows updates.
    3. Rename the c:\programs Data\microsoft\network downloader.old Downloader
    4. Rename C:\Windows\SoftwareDistribution in c:\Windows SoftwareDistribution.old
    5. Rename the Catroot2 Catroot2.old to c:\Windows\System32
    6. Restart the Service of Cryptographic Service, Windows Installer of Module Background Intelligent Transfer and services of Windows updates.
    7. Look for the updates.

    You can also try running the FixIt of http://support.microsoft.com/kb/971058/en-us.

    Concerning

  • I get an error code 646 while trying to download the updates

    I get an error code 646 while trying to download the updates, update security for Microsoft Works 9 (KB2431831)

    Download size: 2.1 MB

    Help, please

    See this thread:

    http://social.answers.Microsoft.com/forums/en-us/vistawu/thread/0c397230-26c6-4214-a5d1-3c99d2b2ef47

  • I'm running into this error message to a sysprep to capture a WIM image modified: "a fatal error has occurred while trying to sysprep the machine."

    Original title: WDS & Sysprep

    Hello

    I'm running into this error message to a sysprep to capture a WIM updated image the:
    3.14 system preparation tool
    "A fatal error has occurred while trying to sysprep the machine."
    She is probably explained by the time of Amendment 3, but is there a way to bypass that force me to change the registry whenever I use the new image?
    Any recommendations on how to solve this problem would be appreciated.
    Thank you.

    GN

    Please post your request here:

  • Error code 2 while trying to update Creative Cloud Desktop Application.

    I get the error code 2 while trying to update Creative Cloud Desktop Application. MacOs 10.9.5. I use Cloud to use Typekit fonts. Now it doesn't work at all. Updete can't and the old version does not work. Can you help me please?

    Sanna, try the following steps.

    1. Delete creative cloud app - https://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html
    2. Install the cloud creative app - https://helpx.adobe.com/creative-cloud/help/install-apps.html
  • Vista Windows which gives error code 800706BA while trying to update

    After my fatal system crash I have recover my system with recovery system after system installed when Vista tries to update it will take longer then three hours his list update failed and afficherdans code 800706BA error help please how to fix this
    .

    MS released a further update for Windows Vista on August 31
    for these receptors error 800706BA while trying to install an update.
    See http://support.microsoft.com/kb/940520 for more details and download
    links. Martin
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • Error code 646. while trying to update, this error code is displayed

    While trying to update, this error code is displayed. What can I do? Y at - there someone who can help me?

    Hello Sergeant115,

    Thank you for using the Microsoft answers Forums.

     

    Solution for error 646:

    Disable all Firewalls and try to install the updates and the stand-alone installation (download manually).

    Reset the Windows Update components

    http://support.Microsoft.com/kb/971058

    Restart the computer after the update is installed.

    Also check with

    http://social.answers.Microsoft.com/forums/en-us/vistawu/thread/6e716883-7af4-4A9F-8665-2f4dd57eee8d

    http://support.Microsoft.com/kb/822798

    That should solve the problem.

    Thank you.

    UDAY $012 please let me know that whether the solution worked or not, I thank you and appreciate your comments. URGO. C

  • error message trying to run a clean boot "an access error was returned while trying to change a service."

    While trying to solve a problem with IE 8, I have a problem trying to run a clean boot.  When I start up I get a message on change in the config file. Click ok and sys config is displayed. Now, if I make a modification, OR not, I get an error message - "an access error was returned while attempting to change a service. You may need to log on using an administrator account to make the specified changes. "First of all I am logged on as administrator, secondly I get this error even when I select"normal start ". I used the clean boot before without problem.  Any ideas?  I am running win xp sp3.  I started having problems after the sp3 upgrade.

    Given that you are not using the standalone SP3 Installer AND since McAfee was working at the time of installation, that's what I'd do (well, I would do it only if I was almost 100% convinced there was no malware on my system):

    1. download the McAfee removal tool.

    2. download the installation file for the free version of Avira AntiVir.

    3. download the standalone SP3 Installer.

    4. download the standalone installer of IE8.

    5. physically disconnect from the Internet.

    6 turn off the automatic updates (temporarily).

    7 uninstall McAfee.

    8 run the McAfee removal tool to make sure that all other loose ends are supported.

    9 Uninstall SP3.

    10. run the system restore, select the before date SP3 has been installed.

    11 uninstall IE8 (and IE7, if necessary). Reason: It is important to be at the level of IE6.

    12 install the SP3. Reset.

    13 Installing IE8. Restart twice.

    14 install AntiVir.

    15 re - connect to the Internet.

    16. download and install the update of AntiVir.

    17 go into Windows Update and install all post-SP3 SECURITY update (stay away from any optional object).

    18 re-rockers automatic updates.

    After the back if you need links to the downloadable.

  • error 193 OXC1 while trying to install PCMatic Supershield.

    I try to install PCMatic Supershield.  I get the error server must be started to install the service.  I went to Services.msc click Server.  It is in automatic mode, but I can't start.  I get the error code 193 OXC1.  I opened services that depend on it and they all run. alone, I don't know is 1xxxx pilot SMB server.   and if you click on this server SMB 2xxxx driver opening.  Don't know how to check these.  I was emailing back to PCMatic for 2 weeks with no resolution.  They finally said try this and sent me to a Web site to buy a remedial program for $100.

    Surely there is a way to fix this without having to buy a $100 service plan.  My experience is that these things are usually false and a RIP-OFF.

    Can someone tell me to do to get the "server started on the Local computer?   I don't have any technical background, but working for several years on computers.  If I can follow the instructions so I can find them.

    Hello Carol,.

    Thank you for visiting Microsoft Community.

    According to the description, you experience the problem with the error code: 193 0xc1 while trying to install PCMatic Supershield.

    I certainly understand your concern and appreciate very much all your efforts to try to solve this problem.

    Given that this problem is related to the server, for more information on this issue, we have a dedicated forum where these issues are dealt with and would be better suited to the TechNet community.

    Please visit the link below to find a community that will provide the best support.

    http://social.technet.Microsoft.com/forums/en-us/home?category=WindowsServer

    I hope this information is useful.

    Please let us know if you need more help, we will be happy to help you.

    Thank you.

     

  • a disk error has occurred while trying to write the following file

    I was working on my video and I put in a video file and a 10 seconds later, I get an error saying "a disk error occurred while trying to write the following file.

    and audio of the video was not working I close Premiere Pro and open again to do the same thing and it happens again if you know how to fix this please tell me I need to change my video so I can get it to the top on youtube tomorrow.Help pls.png

    I contacted support and it turns off everything, I had to do was move the first clip on the desktop... lol Thanks much for the great help! Sorry for the trouble

  • Get the error ORA-39146 while trying to import data from 10 g to 12 c

    Hi all


    im getting below error while trying to import data from 10 g to 12 c


    ORA-39146: schema 'B_SITES' does not exist
    import in WE8MSWIN1252 and AL16UTF16 NCHAR character set
    export in the UTF8 character set and AL16UTF16 NCHAR character set
    ATTENTION: the possible loss of data to character set conversions


    can someone help how do we change to WE8MSWIN1252 UTF8 character set...

    Hello

    "ORA-39146: there is no schema 'B_SITES'.

    ORA-39146: schema 'string' does not exist

    Cause: The specified schema was referenced as the source of a REMAP_SCHEMA parameter, but did not exist in the dump file (for

    Action: Specify the correct name of the schema to be remapped.

    Anand

  • Error ORA-20001 while trying to reset the password of Admin 4.2 Apex

    Hello

    I had to reset my password admin apex and tried to launch as below mentioned the apxchpwd.sql script, but I got an ORA-20001.

    I checked in my console (OEM) the status of the user apex_040200 and status is expired, but not locked...

    Any idea of the reason for the error?

    This is the result I got while running the script:

    Connected to:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    With partitioning, OLAP, Data Mining and Real Application Testing options

    SQL > connect sys@mars as sysdba

    Enter password: *.

    Connected.

    SQL > @apxchpwd

    Syntax: SET SERVEROUTPUT {ON |} {OFF} [SIZE n]

    [[MAST] {WRA [DETERIORATED] |}] WOR [D_WRAPPED] | TRU [NCATED]}]

    Enter a lower value for the password for the user of the Application ADMIN Express.

    Enter a password for the user ADMIN [] *.

    Modified session.

    .. .the ADMIN password

    declare

    *

    ERROR on line 1:

    ORA-20001: password validation failure

    ORA-06512: at line 33 level

    Hello

    In fact, it seems to be a known issue with Apex 4.2.2 and there is a note in Metalink (support.oracle.com) on this subject:Doc ID 1579712.1

    Although it is not documented while the script asks you a new password, you must keep in mind the following:

    Password is not consistent with the rules of this site password complexity.
    * Password must contain at least one alphabetic character ().
    * Password must contain at least one punctuation character ().
    * Password must contain at least one uppercase alphabetic character.
    * Password must contain at least one alphabetic character tiny.

  • error code 663 while trying to install the update for silverlight KB26990729

    Have tried several times to update the two Trend Mico but will not because of the absence of windows vista home premium updates and yet no update will load

    Hello

    Did you last modified the software on the computer?

    I suggest to disable anti-virus and try the steps mentioned below.

    NOTE: Antivirus software can help protect your computer against viruses and other security threats. In most cases, you should not disable your antivirus software. If you need to disable temporarily to install other software, you must reactivate as soon as you are finished. If you are connected to the Internet or a network, while your antivirus software is disabled, your computer is vulnerable to attacks.

    Then I suggest you go through the steps mentioned in the link and the Coachman. You can also run the FIXIT from the link below.

    Method 1:

    Problems with installing updates

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-installing-updates

    If the steps do not help, then you can go to the method 2:

    Method 2:

    I also suggest you go through the steps mentioned in the link and the Coachman.

    You cannot install some programs or updates

    http://support.Microsoft.com/kb/822798

    Method 3:

    You can also try the FIXIT from the link below and check.

    How to manually clean a broken Silverlight installation

    http://blogs.msdn.com/b/rpomeroy/archive/2008/06/10/how-to-manually-clean-up-a-bad-Silverlight-installation.aspx

    If the issue does not help, then you can also post your query to:

    Welcome to the Silverlight.NET Forums

    http://forums.Silverlight.NET/

  • I am receiving and error code 646 while trying to install updates, that which is the cause and how can I solve the problem? Thank you!!

    Windows Update 646 error code

    Option: File of Windows Update agent wups2.dll is incorrectly registered and the registry associated with the Wups2.dll file files are missing.

    Method 1: Save the Windows Update files

    1. Click Start and type notepad in the box start the search.
    2. click on Notepad in the list programs.
    3. copy the following commands, and then paste them into the opened Notepad window:
    REGSVR32 WUPS2. DLL/S
    REGSVR32 STINKS. DLL/S
    REGSVR32 WUAUENG. DLL/S
    REGSVR32 WUAPI. DLL/S
    REGSVR32 WUCLTUX. DLL/S
    REGSVR32 WUWEBV. DLL/S
    REGSVR32 JSCRIPT. DLL/S
    REGSVR32 MSXML3. DLL/S
    4. in Notepad, on the file menu, click Save as.
    5. in the file type list, click all files.
    6. in the file name box, type register.bat.
    7. save the Register.bat file to your desktop.
    8 right-click the Register.bat file, and then click Run as administrator. If you are prompted for an administrator password or a confirmation, type the password or click on continue.
    9. try to reinstall updates.

    http://support.Microsoft.com/kb/958053
    See: method 1: save the Windows Update files

    http://support.Microsoft.com/kb/326253
    Method 5: Registry Windows Update engine files

    http://support.Microsoft.com/kb/971058
    How to reset the Windows Update components?

    Method 2: Download and install Windows Update agent

    Windows Update Agent

    How to get the latest version of the Windows Update Agent to help manage updates on a computer
    http://support.Microsoft.com/kb/949104

    Information for network administrators about how to obtain the latest Windows Update Agent
    http://support.Microsoft.com/kb/946928

    Click Start, click run, click Browse, navigate to the file you saved and click Open.

    Add the switch /wuforce at the end of the command run and then click OK. For example, the command run might look like this: "C:\WindowsUpdateAgent30-x86.exe" /wuforce

    Click run.

    Follow the steps to complete the wizard.

    Important

    To reinstall Windows Update Agent - download the relevant file from one of the links provided above and save it to a drive where Vista is not loaded because the file cannot be launched directly from the root directory of the system.

    Click Start, run, type: "D:\WindowsUpdateAgent30-x86.exe /wuforce" (without the quotes) and press ENTER to install the Windows Update engine.

    Note: There is a space between "D:\WindowsUpdateAgent30-x86.exe" and "/ wuforce.

    D: is the drive where Windows is not installed (IE a flash drive or a 2nd hard drive etc.)

    TaurArian [MVP] 2005-2010 - Update Services

Maybe you are looking for

  • How can I delete my history of my s3

    I don't know how to delete the history

  • X 240 backlit keyboard?

    Hello world Thinking about buying a 240 - X but not all models are equipped with a backlit keyboard (essential for me), I'm looking very carefully... Can someone tell me if the X 240 model ID "20AL007YUK" IS or IS NOT a feature of backlit keyboard? A

  • HP Photosmart C7280 pump motor stalled

    I have a HP Photosmart C7280.  I received a Message from "Pump motor stalled with OK" on my screen.  When I press 'OK', the printer goes through a series of clicks and what looks like the head slide back.  Then I get a message "ink system failure". 

  • Problem with a variable in the SQL statement variable

    Hello I try the following query. HSTMT = DBActivateSQL (hdbc, "UserLevel SELECT FROM ClassUsers WHERE Password =" + string + ""); At this point, I get this error: Operands of + have illegal types "pointer to char" and "pointer to char". I tried this:

  • How to reinstall Vista on a new hard drive in a HP Pavilion dv6-1128tx Entertainment Notebook PC

    Original title: ok, so I have a HP Pavilion dv6-1128tx Entertainment Notebook PC I have a HP Pavilion dv6-1128tx Entertainment Notebook PC right... and my hard drive crashed just completely, I had a new hard drive and now I want again to install wind