DEV Community

Connie Leung
Connie Leung

Posted on

1

Exponential Operator is Supported on Template

Angular 20 will support exponential operator on template.

The feature is in 20.0.0-next.0; therefore, it can be tested after updating the Angular dependencies to the next version.

ng update @angular/cli --next
ng update @angular/core --next
Enter fullscreen mode Exit fullscreen mode

Demo 1: Apply exponential operator on two numbers

<div class="row">
     <p>Case 1: ** operator applied to two integers.</p>
     <p>{{ a }} ** {{ b }} = {{ a ** b }}</p>
</div>

export class AppComponent {
 a = 2;
 b = 3;
}
Enter fullscreen mode Exit fullscreen mode

The result is evaluated to 8 on the template

Demo 2: The exponential operator is right associately

<div class="row">
    <p>Case 2: ** operator is right associative.</p>
    <p>{{ a }} ** {{ b }} ** {{ c }} = {{ a ** b ** c }}</p>
    <p>{{ a }} ** ({{ b }} ** {{ c }}) = {{ a ** (b ** c) }}</p>
 </div>

export class AppComponent {
 a = 2;
 b = 3;
 c = 2;
}
Enter fullscreen mode Exit fullscreen mode

The result is evaluated to 512 on the template.

Demo 3: Parentheses are required around unary operator when it is the base fo the exponential

<div class="row">
     <p>Case 3: parentheses are required around uary operator when it is the base of the ** operator.</p>
      <p>(-2) ** {{ e }} = {{ (-2) ** e }}</p>
      <p>(-2) ** {{ f }} = {{ (-2) ** f }}</p>
</div>

export class AppComponent {
 e = 3;
 f = 4;
}
Enter fullscreen mode Exit fullscreen mode

The result of the first expression is -8 and the result of the second expression is 16.

References:

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

If you found this post useful, please drop a ❤️ or leave a kind comment!

Okay