abs.comp

来自「CNC 的开放码,EMC2 V2.2.8版」· COMP 代码 · 共 35 行

COMP
35
字号
//   This is a component for EMC2 HAL//   Copyright 2006 John Kasunich <jmkasunich at sourceforge dot net>////   This program is free software; you can redistribute it and/or//   modify it under the terms of version 2 of the GNU General//   Public License as published by the Free Software Foundation.////   This program is distributed in the hope that it will be useful,//   but WITHOUT ANY WARRANTY; without even the implied warranty of//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//   GNU General Public License for more details.////   You should have received a copy of the GNU General Public License//   along with this program; if not, write to the Free Software//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USAcomponent abs "Compute the absolute value and sign of the input signal";pin in float in "Analog input value" ;pin out float out "Analog output value, always positive";pin out bit sign "Sign of input, false for positive, true for negative" ;function _;license "GPL";;;FUNCTION(_) {    float tmp = in;    if ( tmp >= 0.0 ) {	sign = 0;	out = tmp;    } else {	sign = 1;	out = -tmp;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?