Changeset 1253 for cpp/frams


Ignore:
Timestamp:
06/22/23 03:27:28 (18 months ago)
Author:
Maciej Komosinski
Message:

Turn -0.0 to 0.0 when the allowed range starts at 0.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/param.cpp

    r1217 r1253  
    1111#include <frams/util/sstringutils.h>
    1212#include <common/virtfile/stringfile.h>
     13#include <common/nonstd_math.h>
    1314
    1415#ifdef _DEBUG
     
    358359{
    359360        SString ret = getName();
    360         if (ret.size()>0) //name might be unavailable, happened in GenMan sub-Params
     361        if (ret.size() > 0) //name might be unavailable, happened in GenMan sub-Params
    361362                ret += ".";
    362363        ret += id(prop);
     
    367368{
    368369        SString name_dot_prop = nameDotProperty(prop);
    369         if (getName()==NULL || getLongName()==NULL) //name/longname might be unavailable, happened in GenMan sub-Params
     370        if (getName() == NULL || getLongName() == NULL) //name/longname might be unavailable, happened in GenMan sub-Params
    370371                return name_dot_prop;
    371        
     372
    372373        if (strcmp(getName(), getLongName()) == 0)
    373374        {
     
    422423        // t+=SString(getName()); t+=':';
    423424        for (i = 0; p = id(i); i++)
    424                 if ((!((fl = flags(i)) & PARAM_DONTSAVE)) && type(i)[0]!='p')
     425                if ((!((fl = flags(i)) & PARAM_DONTSAVE)) && type(i)[0] != 'p')
    425426                {
    426427                        if (defdata && isequal(i, defdata))
     
    716717int ParamInterface::findGroupId(const char* name)
    717718{
    718 for(int i=0;i<getGroupCount();i++)
    719         if (!strcmp(grname(i),name))
    720                 return i;
    721 return -1;
     719        for (int i = 0; i < getGroupCount(); i++)
     720                if (!strcmp(grname(i), name))
     721                        return i;
     722        return -1;
    722723}
    723724
     
    11311132                        if (x < mn) { x = mn; result = PSET_HITMIN; }
    11321133                        else if (x > mx) { x = mx; result = PSET_HITMAX; }
     1134                        clipNegativeZeroIfNeeded(x, mn);  //by the official standard, 0.0 == -0.0 and so it is not true that -0.0 < 0.0, so -0.0 would not be clipped to 0.0, i.e., if we defined the allowed range to be, for example, [0.0, 1.0], then without this call, x==-0.0 would be accepted. Since we never allow x==-0.0 for mn==0 past this point, we don't need to check below if the value changed from -0.0 to 0.0 (which would require comparing old and new std::signbit(x) etc.), because -0.0 could have never been set earlier.
    11331135                }
    11341136
Note: See TracChangeset for help on using the changeset viewer.