Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
communitycreator

What is gmp_neg in PHP?

Hammad Nasir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

gmp_neg is a function in PHP that returns the negative of a GMP number.

The following illustration shows the visual representation of the gmp_neg function.

Visual representation of the gmp_neg function.

Syntax

gmp_neg(GMP|int|string $num): GMP

Parameters

The function takes in one parameter: num.

num can be a numeric string, GMPGNU Multiple Precision Arithmetic Library object, or of theint type.

Return value

The function returns the negative of a number. The value returned is a GMP type number.

Code

<?php
$val1 = gmp_neg("22");
echo gmp_strval($val1) . "\n";
$val2 = gmp_neg("-12456");
echo gmp_strval($val2) . "\n";
?>

Expected output

-22
12456

RELATED TAGS

php
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring