Plex 2E

 View Only
  • 1.  Looking for numeric validation in c 

    Posted Aug 09, 2016 10:14 AM

    While trying to enhance our not-so-good WinC API for numeric validation, I finally decided to give a try to an intrinsic solution, casting a string to a numeric field, forcing a NAN (Not a Number) return when the string field have other than numeric data. But while the check for NAN is a more or less solved issue since c++11, it is a fuzz issue for Visual Studio 2005. There is a function _isnan() available since VS2005, but only since VS2013 all types seems to be covered. For VS2005, there is a limited version, only based on double type, and not very accurate (at least in my test, never get a return > 0, which should be the response for a NAN). Based on my simple research (better discussion here: Checking if a double (or float) is NaN in C++ - Stack Overflow ), it could be a compiler parameters limit (based on /fp (Specify Floating-Point Behavior) ), and it is our case right now: I tried to add in Generate&Build window/custom parameters, for compiler parms the reccomended option /fp:precise in order to ask for DataTest != DataTest which should return true for a NAN, but I can't get any change in behavior.

    Have someone some experience on this issue? some other way to solve it?


    Jorge Ubeda

  • 2.  Re: Looking for numeric validation in c 

    Broadcom Employee
    Posted Aug 25, 2016 04:50 AM

    Hi Jorge,



    I feel sorry ab
    I'm sorry, I do not have an answer about "function_isnan()".

    However, (It is a reverse pattern,) The case which I know is a problem of "C format = Fixed_decimal". This is PTF of Plex which was revised not to return NaN.
    Please see the following URLs.

    Could you please contribute about optional addition to return NaN cord to an ideas?

  • 3.  Re: Looking for numeric validation in c 

    Posted Aug 26, 2016 06:45 AM

    Hi Toshikazu

    Thanks so much for your help. You have introduced the case for the c format fixed decimal...Second document says that its Oracle issue is solved since 7.0 build 001. I imagine it is referred to the involved cast from Oracle to Plex, but I suppose casting a character to a fixed decimal continues giving a NAN...

    Certainly, with the advent of Plex 7.2.1 my issue becomes irrelevant, because I can use at this level c++ isnan routine.

    Actually my question here was related to fine tune our compiling process, in order to apply the /fp:precise parameter to the compiler as reccomended in MSDN.

    By the way, staying yet at VS 2005 level, we replaced our proposed test for NAN, with a detailed and ruled scan of a string, which works.

    Jorge Ubeda

  • 4.  Re: Looking for numeric validation in c 

    Broadcom Employee
    Posted Aug 30, 2016 03:38 AM

    Hi Jorge,
    I looked for a solution, but it was not found.
    You make an analysis program in VS2013, and can API call do it from Plex(VS2005)?
    I hope that this helps you.

  • 5.  Re: Looking for numeric validation in c 

    Posted Aug 30, 2016 03:50 AM

    Hi Toshikazu

    Actually, as said, I solved my numeric validation at level 7.2 (VS2005) with a string based scan. Regarding the possibility of using isnan c++ template it requires at least VS2010. The case is that until Plex 7.2.1, it would be impossible to make an API covering numeric completeness well, but now it is solved. I ignore when we will move to 7.2.1, but there is a solution ahead now.

    With regards


  • 6.  Re: Looking for numeric validation in c 

    Posted Aug 30, 2016 05:37 AM

    second point: several conversations, like the one at StackOverflow, points to the query for NAN as a valid way to test numeric at VS2005 level. However, it is required to define the /fp parameter to the compiler, as said in MSDN:

    The compiler correctly handles comparisons that involve NaN. For example, x != x evaluates to true if x is NaN and ordered comparisons involving NaN raise an exception.

    Then, I have added to User Build Settings from Generate & Build options that /fp:precise compiler parameter, both for internal and external c++ functions, but source code continued not detecting NAN. Originally my question here was about the use and known results of that parameter. Indeed, if I get this option working, I would replace my current string focused validation by another one shorter.