zoukankan      html  css  js  c++  java
  • CompareValue 浮点数比较

    -1 LessThanValue The first value is less than the second value.
    0 EqualsValue The two values are equal.
    1 GreaterThanValue

    var
      A : Single;
      B : Single;
      C : Single;

    begin
      A := 23.0;
      B := 23.0;
      C := 23.1;

      // Compare 2 equal floats
      case CompareValue(A, B) of
        LessThanValue    : ShowMessage('A < B');
        EqualsValue      : ShowMessage('A = B');
        GreaterThanValue : ShowMessage('A > B');
      end;

      // Compare 2 unequal floats
      case CompareValue(A, C) of
        LessThanValue    : ShowMessage('A < C');
        EqualsValue      : ShowMessage('A = C');
        GreaterThanValue : ShowMessage('A > C');
      end;

      // Compare 2 unequal floats - but allow for a difference of up to +/- 0.2
      case CompareValue(A, C, 0.2) of
        LessThanValue    : ShowMessage('A < C');
        EqualsValue      : ShowMessage('A = C');
        GreaterThanValue : ShowMessage('A > C');
      end;
    end;
  • 相关阅读:
    【git】之常用命令
    VueJs
    如何做技术选型
    用户登录验证注意事项
    npm xss
    express-session
    ejs、jade和dust
    XMLHttpRequest.responseType
    JS对象字面量
    安装Angulr CLI
  • 原文地址:https://www.cnblogs.com/luckForever/p/7254648.html
Copyright © 2011-2022 走看看