Yogesh Chauhan's Blog

ABS and NEG functions in Envision Basic

in Envision Basic on December 25, 2021

In Envision basic, there are many useful functions that comes handy. Especially when performing some quick mathematical operations, it saves us a few lines of code.

ABS and NEG are a couple of those kinds of functions that comes handy for math operations.

These functions are really easy to use and mostly don’t require any complex logic to use them.

ABS Function

The ABS function is nothing but an absolute value function. It returns the positive numeric value of the
argument.

Syntax


ABS(expr)

Example

This will change X.NUMBER variable’s value to a positive 1 from a negative 1.


X.NUMBER = -1
X.NUMBER = ABS(X.NUMBER)

NEG Function

The NEG function changes the value of the passes numeric value to the opposite sign value.

So, if the passes expression is of a positive value, it’ll change it to a negative value and return it.

If the passes expression is of a negative value, it’ll change it to a positive value and return it.

Syntax


NEG(expr)

Example

This will change X.NUMBER variable’s value to a positive 1 from a negative 1.


X.NUMBER = -1
X.NUMBER = NEG(X.NUMBER)

This will change X.NUMBER variable’s value to a negative 1 from a positive 1.


X.NUMBER = 1
X.NUMBER = NEG(X.NUMBER)


Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
Values and Types Basics in JavaScriptJavaScriptWP_Query Class in WordPressWordPressCSS align-items property examplesCSSWordPress: How to find all posts from a custom post type with multiple custom fields values?WordPressHow to add Google Map in WordPress using ACF?WordPressHow to display modal from bottom to top using CSS and JavaScript?CSS