Zero to the zero power
You are encouraged to solve this task according to the task description, using any language you may know.
Some computer programming languages are not exactly consistent (with other computer programming languages)
when raising zero to the zeroth power: 00
- Task
Show the results of raising zero to the zeroth power.
If your computer language objects to 0**0 or 0^0 at compile time, you may also try something like:
x = 0 y = 0 z = x**y say 'z=' z
Show the result here.
And of course use any symbols or notation that is supported in your computer programming language for exponentiation.
- See also
- The Wiki entry: Zero to the power of zero.
- The Wiki entry: Zero to the power of zero: History.
- The MathWorld™ entry: exponent laws.
- Also, in the above MathWorld™ entry, see formula (9): .
- The OEIS entry: The special case of zero to the zeroth power
11l[edit]
print(0 ^ 0)
- Output:
1
8th[edit]
0 0 ^ .
- Output:
1
Action![edit]
INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit
PROC Main()
REAL z,res
Put(125) PutE() ;clear the screen
IntToReal(0,z)
Power(z,z,res)
PrintR(z) Print("^")
PrintR(z) Print("=")
PrintRE(res)
RETURN
- Output:
Screenshot from Atari 8-bit computer
0^0=.9999999998
Ada[edit]
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Long_Integer_Text_IO,
Ada.Long_Long_Integer_Text_IO, Ada.Float_Text_IO, Ada.Long_Float_Text_IO,
Ada.Long_Long_Float_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Long_Integer_Text_IO,
Ada.Long_Long_Integer_Text_IO, Ada.Float_Text_IO, Ada.Long_Float_Text_IO,
Ada.Long_Long_Float_Text_IO;
procedure Test5 is
I : Integer := 0;
LI : Long_Integer := 0;
LLI : Long_Long_Integer := 0;
F : Float := 0.0;
LF : Long_Float := 0.0;
LLF : Long_Long_Float := 0.0;
Zero : Natural := 0;
begin
Put ("Integer 0^0 = ");
Put (I ** Zero, 2); New_Line;
Put ("Long Integer 0^0 = ");
Put (LI ** Zero, 2); New_Line;
Put ("Long Long Integer 0^0 = ");
Put (LLI ** Zero, 2); New_Line;
Put ("Float 0.0^0 = ");
Put (F ** Zero); New_Line;
Put ("Long Float 0.0^0 = ");
Put (LF ** Zero); New_Line;
Put ("Long Long Float 0.0^0 = ");
Put (LLF ** Zero); New_Line;
end Test5;
- Output:
Integer 0^0 = 1 Long Integer 0^0 = 1 Long Long Integer 0^0 = 1 Float 0.0^0 = 1.00000E+00 Long Float 0.0^0 = 1.00000000000000E+00 Long Long Float 0.0^0 = 1.00000000000000000E+00
ALGOL 68[edit]
print( ( 0 ^ 0, newline ) )
- Output:
+1
APL[edit]
0*0
1
AppleScript[edit]
return 0 ^ 0
- Output:
1.0
Applesoft BASIC[edit]
]? 0^0 1
Arturo[edit]
print 0 ^ 0
print 0.0 ^ 0
- Output:
1 1.0
Asymptote[edit]
write("0 ^ 0 = ", 0 ** 0);
AutoHotkey[edit]
MsgBox % 0 ** 0
- Output:
1
AWK[edit]
# syntax: GAWK -f ZERO_TO_THE_ZERO_POWER.AWK
BEGIN {
print(0 ^ 0)
exit(0)
}
- Output:
1
BaCon[edit]
PRINT POW(0, 0)
- Output:
prompt$ ./zerotothezero 1
BASIC[edit]
BASIC256[edit]
print "0 ^ 0 = "; 0 ^ 0
Chipmunk Basic[edit]
10 print "0 ^ 0 = ";0^0
MSX Basic[edit]
10 PRINT "0 ^ 0 = "; 0 ^ 0
QBasic[edit]
PRINT "0 ^ 0 ="; 0 ^ 0
Run BASIC[edit]
print "0 ^ 0 = "; 0 ^ 0
True BASIC[edit]
PRINT "0 ^ 0 ="; 0 ^ 0
END
XBasic[edit]
PROGRAM "progname"
VERSION "0.0000"
IMPORT "xma" 'required for POWER
DECLARE FUNCTION Entry ()
FUNCTION Entry ()
PRINT "0 ^ 0 = "; 0 ** 0
PRINT "0 ^ 0 = "; POWER(0, 0)
END FUNCTION
END PROGRAM
BBC BASIC[edit]
PRINT 0^0
- Output:
1
Bc[edit]
0 ^ 0
- Output:
1
Befunge[edit]
Befunge-93 doesn't have explicit support for exponentiation, but there are a couple of fingerprint extensions for Befunge-98 which add that functionality. The example below makes use of the FPDP fingerprint (double precision floating point).
Note that the result is potentially dependent on the underlying language of the interpreter, but all those tested so far have returned 1. Interpreters that don't support Befunge-98, or don't support this fingerprint, should just terminate (possibly with a warning).
"PDPF"4#@(0F0FYP)@
- Output:
1.000000
BQN[edit]
BQN doesn't specify the details of arithmetic functions; existing implementations use IEEE doubles and the pow
function, giving a result of 1.
0⋆0
- Output:
1
Bracmat[edit]
0^0
- Output:
1
Burlesque[edit]
blsq ) 0.0 0.0?^
1.0
blsq ) 0 0?^
1
C[edit]
This example uses the standard pow
function in the math library.
0^0 is given as 1.
#include <stdio.h>
#include <math.h>
#include <complex.h>
int main()
{
printf("0 ^ 0 = %f\n", pow(0,0));
double complex c = cpow(0,0);
printf("0+0i ^ 0+0i = %f+%fi\n", creal(c), cimag(c));
return 0;
}
- Output:
0 ^ 0 = 1.000000 0+0i ^ 0+0i = nan+nani
C#[edit]
using System;
namespace ZeroToTheZeroeth
{
class Program
{
static void Main(string[] args)
{
double k = Math.Pow(0, 0);
Console.Write("0^0 is {0}", k);
}
}
}
- Output:
0^0 is 1
C++[edit]
#include <iostream>
#include <cmath>
#include <complex>
int main()
{
std::cout << "0 ^ 0 = " << std::pow(0,0) << std::endl;
std::cout << "0+0i ^ 0+0i = " <<
std::pow(std::complex<double>(0),std::complex<double>(0)) << std::endl;
return 0;
}
- Output:
0 ^ 0 = 1 0+0i ^ 0+0i = (nan,nan)
Caché ObjectScript[edit]
ZEROPOW
// default behavior is incorrect:
set (x,y) = 0
w !,"0 to the 0th power (wrong): "_(x**y) ; will output 0
// if one or both of the values is a double, this works
set (x,y) = $DOUBLE(0)
w !,"0 to the 0th power (right): "_(x**y)
quit
- Output:
SAMPLES>do ^ZEROPOW0 to the 0th power (wrong): 0
0 to the 0th power (right): 1
Clojure[edit]
user=> (use 'clojure.math.numeric-tower) user=> (expt 0 0) 1 ; alternative java-interop route: user=> (Math/pow 0 0) 1.0
CLU[edit]
The CLU reference manual doesn't mention the issue, so the fact that it returns 1 in my case could just be an implementation detail.
start_up = proc ()
zz_int: int := 0 ** 0
zz_real: real := 0.0 ** 0.0
po: stream := stream$primary_output()
stream$putl(po, "integer 0**0: " || int$unparse(zz_int))
stream$putl(po, "real 0**0: " || f_form(zz_real, 1, 1))
end start_up
- Output:
integer 0**0: 1 real 0**0: 1.0
COBOL[edit]
identification division.
program-id. zero-power-zero-program.
data division.
working-storage section.
77 n pic 9.
procedure division.
compute n = 0**0.
display n upon console.
stop run.
- Output:
1
ColdFusion[edit]
Classic tag based CFML[edit]
<cfset zeroPowerTag = 0^0>
<cfoutput>"#zeroPowerTag#"</cfoutput>
- Output:
"1"
Script Based CFML[edit]
<cfscript>
zeroPower = 0^0;
writeOutput( zeroPower );
</cfscript>
- Output:
1
Commodore BASIC[edit]
Commodore computers use the up arrow key ↑ as the exponent operator.
- Output:
ready. print 0↑0 1 ready. █
Common Lisp[edit]
> (expt 0 0) 1
Crystal[edit]
puts "Int32: #{0_i32**0_i32}"
puts "Negative Int32: #{-0_i32**-0_i32}"
puts "Float32: #{0_f32**0_f32}"
puts "Negative Float32: #{-0_f32**-0_f32}"
- Output:
Int32: 1 Negative Int32: 1 Float32: 1.0 Negative Float32: 1.0
D[edit]
void main() {
import std.stdio, std.math, std.bigint, std.complex;
writeln("Int: ", 0 ^^ 0);
writeln("Ulong: ", 0UL ^^ 0UL);
writeln("Float: ", 0.0f ^^ 0.0f);
writeln("Double: ", 0.0 ^^ 0.0);
writeln("Real: ", 0.0L ^^ 0.0L);
writeln("pow: ", pow(0, 0));
writeln("BigInt: ", 0.BigInt ^^ 0);
writeln("Complex: ", complex(0.0, 0.0) ^^ 0);
}
- Output:
Int: 1 Ulong: 1 Float: 1 Double: 1 Real: 1 pow: 1 BigInt: 1 Complex: 1+0i
Dart[edit]
import 'dart:math';
void main() {
var resul = pow(0, 0);
print("0 ^ 0 = $resul");
}
- Output:
0 ^ 0 = 1
Dc[edit]
0 0^p
- Output:
1
Delphi[edit]
See Pascal.
EasyLang[edit]
print pow 0 0
EchoLisp[edit]
;; trying the 16 combinations
;; all return the integer 1
(lib 'bigint)
(define zeroes '(integer: 0 inexact=float: 0.000 complex: 0+0i bignum: #0))
(for* ((z1 zeroes) (z2 zeroes)) (write (expt z1 z2)))
→ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Eiffel[edit]
print (0^0)
- Output:
1
Elena[edit]
ELENA 4.x
import extensions;
public program()
{
console.printLine("0^0 is ",0.power:0)
}
- Output:
0^0 is 0
Elixir[edit]
Elixir uses Erlang's :math
for power operations and can handle zero to the zero power.
:math.pow(0,0)
- Output:
1.0
Emacs Lisp[edit]
(expt 0 0)
- Output:
1
EMal[edit]
writeLine(0 ** 0) # an integer
writeLine(0.0 ** 0.0) # a real
- Output:
1 1.0
ERRE[edit]
.....
PRINT(0^0)
.....
- Output:
1
F#[edit]
In the REPL:
> let z = 0.**0.;; val z : float = 1.0
Factor[edit]
USING: math.functions.private ; ! ^complex
0 0 ^
C{ 0 0 } C{ 0 0 } ^complex
- Output:
--- Data stack: NAN: 8000000000000 C{ NAN: 8000000000000 NAN: 8000000000000 }
Falcon[edit]
VBA/Python programmer's approach not sure if it's the most falconic way
/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */
x = 0
y = 0
z = x**y
> "z=", z
- Output:
z=1 [Finished in 0.2s]
Fermat[edit]
0^0
- Output:
1
Forth[edit]
0e 0e f** f.
- Output:
1.
Of course in an embedded program we would be tempted to "pre-calculate" the answer :-)
: ^0 DROP 1 ;
- Output:
0 ^0 . 1 ok
Fortran[edit]
program zero
double precision :: i, j
double complex :: z1, z2
i = 0.0D0
j = 0.0D0
z1 = (0.0D0,0.0D0)
z2 = (0.0D0,0.0D0)
write(*,*) 'When integers are used, we have 0^0 = ', 0**0
write(*,*) 'When double precision numbers are used, we have 0.0^0.0 = ', i**j
write(*,*) 'When complex numbers are used, we have (0.0+0.0i)^(0.0+0.0i) = ', z1**z2
end program
- Output:
When integers are used, we have 0^0 = 1 When double precision numbers are used, we have 0.0^0.0 = 1.0000000000000000 When complex numbers are used, we have (0.0+0.0i)^(0.0+0.0i) = ( NaN, NaN)
FreeBASIC[edit]
' FB 1.05.0 Win64
Print "0 ^ 0 ="; 0 ^ 0
Sleep
- Output:
0 ^ 0 = 1
Frink[edit]
println[0^0]
- Output:
1
FutureBasic[edit]
window 1
print 0^0
HandleEvents
Output:
1
Gambas[edit]
Click this link to run this code
Public Sub Main()
Print 0 ^ 0
End
Output:
1
GAP[edit]
0^0;
- Output:
1
Go[edit]
Go does not have an exponentiation operator but has functions in the standard library for three types, float64, complex128, and big.Int. As of Go 1.3, all are documented to return 1.
package main
import (
"fmt"
"math"
"math/big"
"math/cmplx"
)
func main() {
fmt.Println("float64: ", math.Pow(0, 0))
var b big.Int
fmt.Println("big integer:", b.Exp(&b, &b, nil))
fmt.Println("complex: ", cmplx.Pow(0, 0))
}
- Output:
float64: 1 big integer: 1 complex: (1+0i)
Golfscript[edit]
0 0?
- Output:
1
Groovy[edit]
Test:
println 0**0
- Output:
1
GW-BASIC[edit]
PRINT 0^0
- Output:
1
Haskell[edit]
import Data.Complex ( Complex((:+)) )
main :: IO ()
main = mapM_ print [
0 ^ 0,
0.0 ^ 0,
0 ^^ 0,
0 ** 0,
(0 :+ 0) ^ 0,
(0 :+ 0) ** (0 :+ 0)
]
- Output:
1 1.0 1.0 1.0 1.0 :+ 0.0 1.0 :+ 0.0
HolyC[edit]
F64 a = 0 ` 0;
Print("0 ` 0 = %5.3f\n", a);
- Output:
0 ` 0 = 1.000
Icon and Unicon[edit]
"Works" in both languages:
procedure main()
write(0^0)
end
- Output:
->z2z Run-time error 204 File z2z.icn; Line 2 real overflow, underflow, or division by zero Traceback: main() {0 ^ 0} from line 2 in z2z.icn ->
J[edit]
0 ^ 0
1
Note also that this is the multiplicative identity (which means that it's consistent with 1*0
representing 0^1
and with 1*0*0
representing 0^2
and with 1*0*0*0
representing 0^3
and with 1*2*2*2
representing 2^3
and so on. Also, this is the result of finding the product of an empty list:
*/''
1
(In */''
we're finding the product of a list which contains no characters. This is, of course, the same as the product of a list which contains no numbers when both lists contain neither. That said, characters are outside the domain of multiplication in J, so if the list had contained any characters the product would have been an error rather than a result.)
Java[edit]
System.out.println(Math.pow(0, 0));
- Output:
1.0
JavaScript[edit]
Math.pow[edit]
In interactive mode:
> Math.pow(0, 0);
1
exponentiation operator (**)[edit]
> 0**0
1
jq[edit]
Also works with gojq and fq
$ jq -n 'pow(0;0)' 1
It is also worth noting that in jq, gojq, and fq, `pow(0; infinite)` yields 0.
Jsish[edit]
puts(Math.pow(0,0));
- Output:
1
Julia[edit]
Try all combinations of complex, float, rational, integer and boolean.
using Printf
const types = (Complex, Float64, Rational, Int, Bool)
for Tb in types, Te in types
zb, ze = zero(Tb), zero(Te)
r = zb ^ ze
@printf("%10s ^ %-10s = %7s ^ %-7s = %-12s (%s)\n", Tb, Te, zb, ze, r, typeof(r))
end
- Output:
Complex ^ Complex = 0 + 0im ^ 0 + 0im = 1.0 + 0.0im (Complex{Float64}) Complex ^ Float64 = 0 + 0im ^ 0.0 = 1.0 + 0.0im (Complex{Float64}) Complex ^ Rational = 0 + 0im ^ 0//1 = 1.0 + 0.0im (Complex{Float64}) Complex ^ Int64 = 0 + 0im ^ 0 = 1 + 0im (Complex{Int64}) Complex ^ Bool = 0 + 0im ^ false = 1 + 0im (Complex{Int64}) Float64 ^ Complex = 0.0 ^ 0 + 0im = 1.0 + 0.0im (Complex{Float64}) Float64 ^ Float64 = 0.0 ^ 0.0 = 1.0 (Float64) Float64 ^ Rational = 0.0 ^ 0//1 = 1.0 (Float64) Float64 ^ Int64 = 0.0 ^ 0 = 1.0 (Float64) Float64 ^ Bool = 0.0 ^ false = 1.0 (Float64) Rational ^ Complex = 0//1 ^ 0 + 0im = 1.0 + 0.0im (Complex{Float64}) Rational ^ Float64 = 0//1 ^ 0.0 = 1.0 (Float64) Rational ^ Rational = 0//1 ^ 0//1 = 1.0 (Float64) Rational ^ Int64 = 0//1 ^ 0 = 1//1 (Rational{Int64}) Rational ^ Bool = 0//1 ^ false = 1//1 (Rational{Int64}) Int64 ^ Complex = 0 ^ 0 + 0im = 1.0 + 0.0im (Complex{Float64}) Int64 ^ Float64 = 0 ^ 0.0 = 1.0 (Float64) Int64 ^ Rational = 0 ^ 0//1 = 1.0 (Float64) Int64 ^ Int64 = 0 ^ 0 = 1 (Int64) Int64 ^ Bool = 0 ^ false = 1 (Int64) Bool ^ Complex = false ^ 0 + 0im = 1.0 + 0.0im (Complex{Float64}) Bool ^ Float64 = false ^ 0.0 = 1.0 (Float64) Bool ^ Rational = false ^ 0//1 = 1.0 (Float64) Bool ^ Int64 = false ^ 0 = true (Bool) Bool ^ Bool = false ^ false = true (Bool)
K[edit]
0^0
1.0
Klingphix[edit]
:mypower
dup not (
[ drop sign dup 0 equal [ drop 1 ] if ]
[ power ]
) if
;
0 0 mypower print nl
"End " input
- Output:
1 End
Kotlin[edit]
import kotlin.math.pow
fun main() {
println(0.0.pow(0))
}
- Output:
1.0
Lambdatalk[edit]
{pow 0 0}
-> 1
{exp 0 0}
-> 1
Liberty BASIC[edit]
'********
print 0^0
'********
- Output:
1
Locomotive Basic[edit]
print 0🠅0
- Output:
1
Lua[edit]
No need to try different data types or with / without decimal points as all numbers in Lua are stored in double-precision floating-point format.
print(0^0)
- Output:
1
M2000 Interpreter[edit]
M2000 use ** and ^ for power.
Module Checkit {
x=0
y=0
Print x**y=1, x^y=1 ' True True
}
Checkit
Maple[edit]
0^0
- Output:
1
However, for consistency with IEEE-754 numerics, we also have a NaN result for the equivalent floating-point exponentiation:
0^0.0
- Output:
Float(undefined)
Mathematica/Wolfram Language[edit]
0^0
- Output:
Indeterminate
MATLAB / Octave[edit]
0^0
complex(0,0)^0
- Output:
1 1
Maxima[edit]
0^0;
- Output:
0 expt: undefined: 0
Mercury[edit]
:- module zero_to_the_zero_power.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module float, int, integer, list, string.
main(!IO) :-
io.format(" int.pow(0, 0) = %d\n", [i(pow(0, 0))], !IO),
io.format("integer.pow(zero, zero) = %s\n",
[s(to_string(pow(zero, zero)))], !IO),
io.format(" float.pow(0.0, 0) = %.1f\n", [f(pow(0.0, 0))], !IO).
:- end_module zero_to_the_zero_power.
- Output:
int.pow(0, 0) = 1 integer.pow(zero, zero) = 1 float.pow(0.0, 0) = 1.0
Microsoft Small Basic[edit]
TextWindow.WriteLine(Math.Power(0,0))
- Output:
1
min[edit]
0 0 pow puts
- Output:
1.0
MiniScript[edit]
print "The result of zero to the zero power is " + 0^0
- Output:
The result of zero to the zero power is 1
МК-61/52[edit]
Сx ^ x^y С/П
The result is error message.
Nanoquery[edit]
println 0^0
- Output:
1
Neko[edit]
Neko uses the C math library for exponentiation, Zero to the zero in math.pow(x, y) is treated as being 1.
/**
Zero to the zeroth power, in Neko
*/
var math_pow = $loader.loadprim("std@math_pow", 2)
$print(math_pow(0, 0), "\n")
- Output:
prompt$ nekoc zero-to-the-zero.neko prompt$ neko zero-to-the-zero.n 1
NetRexx[edit]
x=0
Say '0**0='||x**x
- Output:
0**0=1
NewLISP[edit]
(pow 0 0)
- Output:
1
Nial[edit]
Create an exponentiation table for all type combinations (of integer 0
, float 0.0
and boolean o
):
0 0.0 o outer power 0 0.0 o
+--+--+--+
| 1|1.| 1|
+--+--+--+
|1.|1.|1.|
+--+--+--+
| 1|1.| 1|
+--+--+--+
Nim[edit]
import math
echo pow(0.0, 0.0) # Floating point exponentiation.
echo 0 ^ 0 # Integer exponentiation.
- Output:
1.0 1
OCaml[edit]
In the interpreter:
# 0.0 ** 0.0;; - : float = 1. # Complex.pow Complex.zero Complex.zero;; - : Complex.t = {Complex.re = nan; Complex.im = nan} # #load "nums.cma";; # open Num;; # Int 0 **/ Int 0;; - : Num.num = Int 1
Oforth[edit]
0 0 pow println
- Output:
1
Ol[edit]
(print "0^0: " (expt 0 0))
(print "0.0^0: " (expt (inexact 0) 0))
- Output:
0^0: 1 0.0^0: 1
ooRexx[edit]
/**********************************************************************
* 21.04.2014 Walter Pachl
**********************************************************************/
Say 'rxCalcpower(0,0) ->' rxCalcpower(0,0)
Say '0**0 ->' 0**0
::requires rxmath library
- Output:
rxCalcpower(0,0) -> 1 0**0 -> 1
Openscad[edit]
echo (0^0);
PARI/GP[edit]
0 raised to the power of exact 0 is 1, but 0 cannot be raised to the power of an inexact 0:
0^0
0.^0
0^0.
- Output:
%1 = 1 %2 = 1 *** at top-level: 0^0. *** ^--- *** _^_: domain error in gpow(0,n): n <= 0 *** Break loop: type 'break' to go back to GP prompt
Pascal[edit]
program ZToZ;
uses
math;
begin
write('0.0 ^ 0 :',IntPower(0.0,0):4:2);
writeln(' 0.0 ^ 0.0 :',Power(0.0,0.0):4:2);
end.
- output
0.0 ^ 0 :1.00 0.0 ^ 0.0 :1.00
Perl[edit]
print 0 ** 0, "\n";
use Math::Complex;
print cplx(0,0) ** cplx(0,0), "\n";
- Output:
1 1
Phix[edit]
?power(0,0) requires("0.8.4") -- (now fixed/crashes on earlier versions) include complex.e complex a = complex_new(0,0), b = complex_power(a,a) string sa = complex_sprint(a,true), sb = complex_sprint(b,true) printf(1,"%s ^ %s = %s\n",{sa,sa,sb})
- Output:
1 0+0i ^ 0+0i = 1+0i
Phixmonti[edit]
def mypower
dup not if
. sign dup 0 == if . 1 endif
else
power
endif
enddef
0 0 mypower print
- Output:
1
PHP[edit]
<?php
echo pow(0,0);
echo 0 ** 0; // PHP 5.6+ only
?>
- Output:
1 1
PicoLisp[edit]
(** 0 0)
- Output:
1
Pike[edit]
write( pow(0, 0) +"\n" );
- Output:
1
PL/I[edit]
zhz: Proc Options(Main);
Dcl a dec float(10) Init(1);
Dcl b dec float(10) Init(0);
Put skip list('1**0=',a**b);
Put skip list('0**1=',b**a);
Put skip list('0**0=',b**b);
End;
- Output:
1**0= 1.000000000E+0000 0**1= 0.000000000E+0000 0**0= IBM0682I ONCODE=1553 X in EXPONENT(X) was invalid. At offset +0000025B in procedure with entry ZHZ
Plain English[edit]
To run:
Start up.
Put 0 into a number.
Raise the number to 0.
Convert the number to a string.
Write the string to the console.
Wait for the escape key.
Shut down.
- Output:
1
PowerShell[edit]
Write-Host "0 ^ 0 = " ([math]::pow(0,0))
Output :
0 ^ 0 = 1
PureBasic[edit]
If OpenConsole()
PrintN("Zero to the zero power is " + Pow(0,0))
PrintN("")
PrintN("Press any key to close the console")
Repeat: Delay(10) : Until Inkey() <> ""
CloseConsole()
EndIf
- Output:
Zero to the zero power is 1
Pyret[edit]
num-expt(0, 0)
- Output:
1
Python[edit]
Python3[edit]
from decimal import Decimal
from fractions import Fraction
from itertools import product
zeroes = [0, 0.0, 0j, Decimal(0), Fraction(0, 1), -0.0, -0.0j, Decimal(-0.0)]
for i, j in product(zeroes, repeat=2):
try:
ans = i**j
except:
ans = '<Exception raised>'
print(f'{i!r:>15} ** {j!r:<15} = {ans!r}')
- Output:
0 ** 0 = 1 0 ** 0.0 = 1.0 0 ** 0j = (1+0j) 0 ** Decimal('0') = '<Exception raised>' 0 ** Fraction(0, 1) = 1 0 ** -0.0 = 1.0 0 ** (-0-0j) = (1+0j) 0 ** Decimal('-0') = '<Exception raised>' 0.0 ** 0 = 1.0 0.0 ** 0.0 = 1.0 0.0 ** 0j = (1+0j) 0.0 ** Decimal('0') = '<Exception raised>' 0.0 ** Fraction(0, 1) = 1.0 0.0 ** -0.0 = 1.0 0.0 ** (-0-0j) = (1+0j) 0.0 ** Decimal('-0') = '<Exception raised>' 0j ** 0 = (1+0j) 0j ** 0.0 = (1+0j) 0j ** 0j = (1+0j) 0j ** Decimal('0') = '<Exception raised>' 0j ** Fraction(0, 1) = (1+0j) 0j ** -0.0 = (1+0j) 0j ** (-0-0j) = (1+0j) 0j ** Decimal('-0') = '<Exception raised>' Decimal('0') ** 0 = '<Exception raised>' Decimal('0') ** 0.0 = '<Exception raised>' Decimal('0') ** 0j = '<Exception raised>' Decimal('0') ** Decimal('0') = '<Exception raised>' Decimal('0') ** Fraction(0, 1) = '<Exception raised>' Decimal('0') ** -0.0 = '<Exception raised>' Decimal('0') ** (-0-0j) = '<Exception raised>' Decimal('0') ** Decimal('-0') = '<Exception raised>' Fraction(0, 1) ** 0 = Fraction(1, 1) Fraction(0, 1) ** 0.0 = 1.0 Fraction(0, 1) ** 0j = (1+0j) Fraction(0, 1) ** Decimal('0') = '<Exception raised>' Fraction(0, 1) ** Fraction(0, 1) = Fraction(1, 1) Fraction(0, 1) ** -0.0 = 1.0 Fraction(0, 1) ** (-0-0j) = (1+0j) Fraction(0, 1) ** Decimal('-0') = '<Exception raised>' -0.0 ** 0 = 1.0 -0.0 ** 0.0 = 1.0 -0.0 ** 0j = (1+0j) -0.0 ** Decimal('0') = '<Exception raised>' -0.0 ** Fraction(0, 1) = 1.0 -0.0 ** -0.0 = 1.0 -0.0 ** (-0-0j) = (1+0j) -0.0 ** Decimal('-0') = '<Exception raised>' (-0-0j) ** 0 = (1+0j) (-0-0j) ** 0.0 = (1+0j) (-0-0j) ** 0j = (1+0j) (-0-0j) ** Decimal('0') = '<Exception raised>' (-0-0j) ** Fraction(0, 1) = (1+0j) (-0-0j) ** -0.0 = (1+0j) (-0-0j) ** (-0-0j) = (1+0j) (-0-0j) ** Decimal('-0') = '<Exception raised>' Decimal('-0') ** 0 = '<Exception raised>' Decimal('-0') ** 0.0 = '<Exception raised>' Decimal('-0') ** 0j = '<Exception raised>' Decimal('-0') ** Decimal('0') = '<Exception raised>' Decimal('-0') ** Fraction(0, 1) = '<Exception raised>' Decimal('-0') ** -0.0 = '<Exception raised>' Decimal('-0') ** (-0-0j) = '<Exception raised>' Decimal('-0') ** Decimal('-0') = '<Exception raised>'
Python2[edit]
from decimal import Decimal
from fractions import Fraction
for n in (Decimal(0), Fraction(0, 1), complex(0), float(0), int(0)):
try:
n1 = n**n
except:
n1 = '<Raised exception>'
try:
n2 = pow(n, n)
except:
n2 = '<Raised exception>'
print('%8s: ** -> %r; pow -> %r' % (n.__class__.__name__, n1, n2))
- Output:
Decimal: ** -> '<Raised exception>'; pow -> '<Raised exception>' Fraction: ** -> Fraction(1, 1); pow -> Fraction(1, 1) complex: ** -> (1+0j); pow -> (1+0j) float: ** -> 1.0; pow -> 1.0 int: ** -> 1; pow -> 1
QB64[edit]
Print 0 ^ 0
- Output:
1
Alternatively:
i% = 0 'Integer
l& = 0 'Long integer
s! = 0.0 'Single precision floating point
d# = 0.0 'Double precision floating point
b` = 0 '_Bit
bb%% = 0 '_Byte
isf&& = 0 '_Integer64
Print i% ^ i%
Print l& ^ l&
Print s! ^ s!
Print d# ^ d#
Print b` ^ b`
Print bb%% ^ bb%%
Print isf&& ^ isf&&
- Output:
NB: Values with 0 decimals are trimmed by Print's casting from number value to String.
1 1 1 1 1 1 1
Quackery[edit]
As a dialogue in the Quackery shell.
/O> 0 0 **
...
Stack: 1
R[edit]
print(0^0)
- Output:
1
Racket[edit]
#lang racket
;; as many zeros as I can think of...
(define zeros (list
0 ; unspecified number type
0. ; hinted as float
#e0 ; explicitly exact
#i0 ; explicitly inexact
0+0i ; exact complex
0.+0.i ; float inexact
))
(for*((z zeros) (p zeros))
(printf "(~a)^(~a) = ~s~%" z p
(with-handlers [(exn:fail:contract:divide-by-zero? exn-message)]
(expt z p))))
- Output:
(0)^(0) = 1 (0)^(0.0) = 1.0 (0)^(0) = 1 (0)^(0.0) = 1.0 (0)^(0) = 1 (0)^(0.0+0.0i) = "expt: undefined for 0 and 0.0+0.0i" (0.0)^(0) = 1 (0.0)^(0.0) = 1.0 (0.0)^(0) = 1 (0.0)^(0.0) = 1.0 (0.0)^(0) = 1 (0.0)^(0.0+0.0i) = +nan.0+nan.0i (0)^(0) = 1 (0)^(0.0) = 1.0 (0)^(0) = 1 (0)^(0.0) = 1.0 (0)^(0) = 1 (0)^(0.0+0.0i) = "expt: undefined for 0 and 0.0+0.0i" (0.0)^(0) = 1 (0.0)^(0.0) = 1.0 (0.0)^(0) = 1 (0.0)^(0.0) = 1.0 (0.0)^(0) = 1 (0.0)^(0.0+0.0i) = +nan.0+nan.0i (0)^(0) = 1 (0)^(0.0) = 1.0 (0)^(0) = 1 (0)^(0.0) = 1.0 (0)^(0) = 1 (0)^(0.0+0.0i) = "expt: undefined for 0 and 0.0+0.0i" (0.0+0.0i)^(0) = 1 (0.0+0.0i)^(0.0) = 1.0+0.0i (0.0+0.0i)^(0) = 1 (0.0+0.0i)^(0.0) = 1.0+0.0i (0.0+0.0i)^(0) = 1 (0.0+0.0i)^(0.0+0.0i) = +nan.0+nan.0i
Raku[edit]
(formerly Perl 6)
say ' type n n**n exp(n,n)';
say '-------- -------- -------- --------';
for 0, 0.0, FatRat.new(0), 0e0, 0+0i {
printf "%8s %8s %8s %8s\n", .^name, $_, $_**$_, exp($_,$_);
}
- Output:
type n n**n exp(n,n) -------- -------- -------- -------- Int 0 1 1 Rat 0 1 1 FatRat 0 1 1 Num 0 1 1 Complex 0+0i 1+0i 1+0i
Red[edit]
Shown using the operator, the function, and the math
mini-DSL that uses the order of operations from mathematics:
Red[]
print 0 ** 0
print power 0 0
print math [0 ** 0]
- Output:
1 1 1
Relation[edit]
echo pow(0,0)
// 1
REXX[edit]
/*REXX program shows the results of raising zero to the zeroth power.*/
say '0 ** 0 (zero to the zeroth power) ───► ' 0**0
using PC/REXX
using Personal REXX
using REGINA
using ooRexx
- Output:
0 ** 0 (zero to the zeroth power) ───► 1
using R4
- Output:
Error 26 : Invalid whole number (SYNTAX) Information: 0 ** 0 is undefined Error occurred in statement# 2 Statement source: say '0 ** 0 (zero to the zeroth power) ───► ' 0**0 Statement context: C:\ZERO_TO0.REX, procedure: ZERO_TO0
using ROO
- Output:
Error 26 : Invalid whole number (SYNTAX) Information: 0 ** 0 is undefined Error occurred in statement# 2 Statement source: say '0 ** 0 (zero to the zeroth power) ───► ' 0**0 Statement context: C:\ZERO_TO0.REX, procedure: ZERO_TO0
Ring[edit]
x = 0
y = 0
z = pow(x,y)
see "z=" + z + nl # z=1
RPL[edit]
0 0 ^
- Output:
1: 1
Ruby[edit]
require 'bigdecimal'
[0, 0.0, Complex(0), Rational(0), BigDecimal("0")].each do |n|
printf "%10s: ** -> %s\n" % [n.class, n**n]
end
- Output:
Integer: ** -> 1 Float: ** -> 1.0 Complex: ** -> 1+0i Rational: ** -> 1/1 BigDecimal: ** -> 0.1e1
Rust[edit]
fn main() {
println!("{}",0u32.pow(0));
}
- Output:
1
S-lang[edit]
print(0^0);
- Output:
1.0
Scala[edit]
assert(math.pow(0, 0) == 1, "Scala blunder, should go back to school !")
Scheme[edit]
(display (expt 0 0)) (newline)
(display (expt 0.0 0.0)) (newline)
(display (expt 0+0i 0+0i)) (newline)
- Output:
1 1.0 1.0
Seed7[edit]
$ include "seed7_05.s7i";
include "float.s7i";
include "complex.s7i";
const proc: main is func
begin
writeln("0 ** 0 = " <& 0 ** 0);
writeln("0.0 ** 0 = " <& 0.0 ** 0);
writeln("0.0 ** 0.0 = " <& 0.0 ** 0.0);
writeln("0.0+0i ** 0 = " <& complex(0.0) ** 0);
end func;
- Output:
0 ** 0 = 1 0.0 ** 0 = 1.0 0.0 ** 0.0 = 1.0 0.0+0i ** 0 = 1.0+0.0i
SenseTalk[edit]
set a to 0
set b to 0
put a to the power of b
// Prints: 1
Sidef[edit]
[0, Complex(0, 0)].each {|n|
say n**n
}
- Output:
1 1
Taking the 0'th root of a number and raising it back to the zero power, we also get a 1:
say 0.root(0).pow(0) # => 1
say ((0**(1/0))**0) # => 1
Sinclair ZX81 BASIC[edit]
PRINT 0**0
- Output:
1
Smalltalk[edit]
0 raisedTo: 0
0.0 raisedTo: 0.0
- Output:
1 1.0
smart BASIC[edit]
PRINT 0^0
- Output:
1
SNOBOL4[edit]
OUTPUT = (0 ** 0)
END
SQL[edit]
SQL> select power(0,0) from dual;
- Output:
POWER(0,0) ---------- 1
Standard ML[edit]
In the interpreter:
- Math.pow (0.0, 0.0); val it = 1.0 : real
Stata[edit]
. display 0^0
1
Swift[edit]
import Darwin
print(pow(0.0,0.0))
- Output:
1.0
Symsyn[edit]
(0^0) []
- Output:
1
Tcl[edit]
Interactively…
% expr 0**0
1
% expr 0.0**0.0
1.0
TI SR-56[edit]
0 Yx 0 =
- Output:
1
TI-83_BASIC[edit]
0^0
- Output:
ERROR:DOMAIN
uBasic/4tH[edit]
Print 0^0
- Output:
1 0 OK, 0:9
Ursa[edit]
Cygnus/X Ursa is written in Java, and as a result returns 1.0 when raising 0 to the 0.
> out (pow 0 0) endl console
1.0
VBA[edit]
Public Sub zero()
x = 0
y = 0
z = 0 ^ 0
Debug.Print "z ="; z
End Sub
- Output:
z = 1
VBScript[edit]
WScript.Echo 0 ^ 0
- Output:
1
Verilog[edit]
module main;
initial begin
$display("0 ^ 0 = ", 0**0);
$finish ;
end
endmodule
- Output:
0 ^ 0 = 1
Visual Basic .NET[edit]
Module Program
Sub Main()
Console.Write(0^0)
End Sub
End Module
- Output:
1
V (Vlang)[edit]
// Zero to the zero power, in V
// Tectonics: v run zero-to-the-zero-power.v
module main
import math
// starts here
// V does not include an exponentiation operator, but uses a math module
pub fn main() {
println(math.pow(0, 0))
}
- Output:
prompt$ v run rosetta/zero-to-the-zero-power.v 1.
Wren[edit]
System.print(0.pow(0))
- Output:
1
XLISP[edit]
XLISP 3.3, September 6, 2002 Copyright (c) 1984-2002, by David Betz
[1] (expt 0 0)
1
[2]
XPL0[edit]
RlOut(0, Pow(0., 0.))
- Output:
1.00000
Zig[edit]
const std = @import("std");
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
try stdout.print("0^0 = {d:.8}\n", .{std.math.pow(f32, 0, 0)});
}
- Output:
0^0 = 1.00000000
zkl[edit]
(0.0).pow(0) //--> 1.0
var BN=Import("zklBigNum"); // big ints
BN(0).pow(0) //--> 1
- Pages with syntax highlighting errors
- Programming Tasks
- Solutions by Programming Task
- Simple
- 6502 Assembly/Omit
- 8080 Assembly/Omit
- Computer/zero Assembly/Omit
- Z80 Assembly/Omit
- 68000 Assembly/Omit
- 8086 Assembly/Omit
- MIPS Assembly/Omit
- ARM Assembly/Omit
- 11l
- 8th
- AArch64 Assembly/Omit
- Action!
- Action! Tool Kit
- Ada
- ALGOL 68
- APL
- AppleScript
- Applesoft BASIC
- Arturo
- Asymptote
- AutoHotkey
- AWK
- BaCon
- BASIC
- BASIC256
- Chipmunk Basic
- MSX Basic
- QBasic
- Run BASIC
- True BASIC
- XBasic
- BBC BASIC
- Bc
- Befunge
- BQN
- Bracmat
- Burlesque
- C
- C sharp
- C++
- Caché ObjectScript
- Clojure
- CLU
- COBOL
- ColdFusion
- Commodore BASIC
- Common Lisp
- Crystal
- D
- Dart
- Dc
- Delphi
- EasyLang
- EchoLisp
- Eiffel
- Elena
- Elixir
- Emacs Lisp
- EMal
- ERRE
- F Sharp
- Factor
- Falcon
- Fermat
- Forth
- Fortran
- FreeBASIC
- Frink
- FutureBasic
- Gambas
- GAP
- Go
- Golfscript
- Groovy
- GW-BASIC
- Haskell
- HolyC
- Icon
- Unicon
- J
- Java
- JavaScript
- Jq
- Jsish
- Julia
- K
- Klingphix
- Kotlin
- Lambdatalk
- Liberty BASIC
- Locomotive Basic
- Lua
- M2000 Interpreter
- Maple
- Mathematica
- Wolfram Language
- MATLAB
- Octave
- Maxima
- Mercury
- Microsoft Small Basic
- Min
- MiniScript
- МК-61/52
- Nanoquery
- Neko
- NetRexx
- NewLISP
- Nial
- Nim
- OCaml
- Oforth
- Ol
- OoRexx
- Openscad
- PARI/GP
- Pascal
- Math
- Perl
- Phix
- Phix/basics
- Phixmonti
- PHP
- PicoLisp
- Pike
- PL/I
- Plain English
- PowerShell
- PureBasic
- Pyret
- Python
- QB64
- Quackery
- R
- Racket
- Raku
- Red
- Relation
- REXX
- Ring
- RPL
- Ruby
- Rust
- S-lang
- Scala
- Scheme
- Seed7
- SenseTalk
- Sidef
- Sinclair ZX81 BASIC
- Smalltalk
- Smart BASIC
- SNOBOL4
- SQL
- Standard ML
- Stata
- Swift
- Symsyn
- Tcl
- TI SR-56
- TI-83 BASIC
- UBasic/4tH
- Ursa
- VBA
- VBScript
- Verilog
- Visual Basic .NET
- V (Vlang)
- Wren
- XLISP
- XPL0
- Zig
- Zkl