DEV Community

Connie Leung
Connie Leung

Posted on

2

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:

Tutorial image

Next.js Tutorial 2025 - Build a Full Stack Social App

In this 4-hour hands-on tutorial, Codesistency walks you through the process of building a social platform from scratch with Next.js (App Router), React, Prisma ORM, Clerk for authentication, Neon for PostgreSQL hosting, Tailwind CSS, Shadcn UI, and UploadThing for image uploads.

Watch the full video ➡

Top comments (1)

Collapse
 
frankeast profile image
FrankEast

Awesome! Template math just got a lot cleaner with the ** operator. 🚀 Cricbet99

ACI image

ACI.dev: Fully Open-source AI Agent Tool-Use Infra (Composio Alternative)

100% open-source tool-use platform (backend, dev portal, integration library, SDK/MCP) that connects your AI agents to 600+ tools with multi-tenant auth, granular permissions, and access through direct function calling or a unified MCP server.

Check out our GitHub!