Zero to the zero power: Difference between revisions

m
(262 intermediate revisions by more than 100 users not shown)
Line 1:
{{draft task}}
[[Category:Simple]]
Some programming languages are not exactly consistent (with other programming languages) when raising zero to the zeroth power: <math>0^0</math>.
{{omit from|6502 Assembly|There is no built in multiplication, let alone exponentiation. Thus the outcome is decided by the programmer not the language.}}
;Task requirements
{{omit from|8080 Assembly|See 6502 Assembly.}}
Show the results of raising zero to the zeroth power.
{{omit from|Computer/zero Assembly|See 6502 Assembly.}}
{{omit from|Z80 Assembly|See 6502 Assembly.}}
{{omit from|68000 Assembly|There is no built-in exponentiation so the programmer's implementation decides the outcome.}}
{{omit from|8086 Assembly|There is no built-in exponentiation so the programmer's implementation decides the outcome.}}
{{omit from|MIPS Assembly|There is no built-in exponentiation so the programmer's implementation decides the outcome.}}
{{omit from|ARM Assembly|See 8086 Assembly.}}
Some computer programming languages are not exactly consistent &nbsp; (with other computer programming languages) &nbsp;
<br>when &nbsp; ''raising zero to the zeroth power'': &nbsp; &nbsp; <b><big>0<sup>0</sup></big></b>
 
 
;Task:
Show the results of raising &nbsp; zero &nbsp; to the &nbsp; zeroth &nbsp; power.
 
 
If your computer language objects to &nbsp; &nbsp; <big> '''0**0''' </big> &nbsp; &nbsp; or &nbsp; &nbsp; <big> '''0^0''' </big> &nbsp; &nbsp; at compile time, &nbsp; you may also try something like:
x = 0
y = 0
z = x**y
say 'z=' z
 
 
'''Show the result here.'''<br>
And of course use any symbols or notation that is supported in your computer programming language for exponentiation.
 
If your computer language objects to <code>0**0</code> at compile time, you may also try something like:
<lang rexx>x = 0
y = 0
z = x**y
··· show the result ···</lang>
Of course, use any symbols or notation that is supported in your computer language for exponentiation.
 
;See also:
* The Wiki entry: [[wp:Exponentiation#Zero_to_the_power_of_zero#History|Zero to the power of zero]].
* The Wiki entry: [[wp:ExponentiationZero_to_the_power_of_zero#History_of_differing_points_of_view|History|Zero ofto differingthe pointspower of viewzero: History]].
* The MathWorld™ entry: [http://mathworld.wolfram.com/ExponentLaws.html exponent laws].
** Also, in the above MathWorld™ entry, see formula ('''9'''): <math>x^0=1</math>.
* The OEIS entry: [https://oeis.org/wiki/The_special_case_of_zero_to_the_zeroth_power The special case of zero to the zeroth power]
<br><br>
 
=={{header|C11l}}==
<syntaxhighlight lang="11l">print(0 ^ 0)</syntaxhighlight>
This example uses the standard <code>pow</code> function in the math library. 0^0 is given as 1.
<lang C>/*Abhishek Ghosh, 18th March 2014, Rotterdam*/
 
{{out}}
#include<stdio.h>
<pre>
#include<math.h>
1
</pre>
 
=={{header|8th}}==
<syntaxhighlight lang="forth">
0 0 ^ .
</syntaxhighlight>
{{out}}
1
{{omit from|AArch64 Assembly}}
 
{{omit from|ARM Assembly}}
 
=={{header|Action!}}==
{{libheader|Action! Tool Kit}}
<syntaxhighlight lang="action!">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</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Zero_to_the_zero_power.png Screenshot from Atari 8-bit computer]
<pre>
0^0=.9999999998
</pre>
 
=={{header|Ada}}==
<syntaxhighlight lang="ada">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;
</syntaxhighlight>
{{out}}
<pre>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
</pre>
 
=={{header|ALGOL 68}}==
{{works with|ALGOL 68G|Any - tested with release 2.6.win32}}
<syntaxhighlight lang="algol68">print( ( 0 ^ 0, newline ) )
</syntaxhighlight>
{{out}}
<pre>
+1
</pre>
 
=={{header|APL}}==
<syntaxhighlight lang="apl"> 0*0
1</syntaxhighlight>
 
=={{header|AppleScript}}==
<syntaxhighlight lang="applescript"> return 0 ^ 0</syntaxhighlight>
 
{{output}}
<syntaxhighlight lang="applescript">1.0</syntaxhighlight>
 
=={{header|Applesoft BASIC}}==
<pre>]? 0^0
1</pre>
 
{{omit from|ARM Assembly}}
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="rebol">print 0 ^ 0
print 0.0 ^ 0</syntaxhighlight>
 
{{out}}
 
<pre>1
1.0</pre>
 
=={{header|Asymptote}}==
<syntaxhighlight lang="asymptote">write("0 ^ 0 = ", 0 ** 0);</syntaxhighlight>
 
=={{header|AutoHotkey}}==
<syntaxhighlight lang="autohotkey">MsgBox % 0 ** 0</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
# syntax: GAWK -f ZERO_TO_THE_ZERO_POWER.AWK
BEGIN {
print(0 ^ 0)
exit(0)
}
</syntaxhighlight>
{{out}}
<pre>
1
</pre>
 
=={{header|BaCon}}==
<syntaxhighlight lang="freebasic">PRINT POW(0, 0)</syntaxhighlight>
 
{{out}}
<pre>prompt$ ./zerotothezero
1</pre>
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">print "0 ^ 0 = "; 0 ^ 0</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
<syntaxhighlight lang="qbasic">10 print "0 ^ 0 = ";0^0</syntaxhighlight>
 
==={{header|MSX Basic}}===
<syntaxhighlight lang="qbasic">10 PRINT "0 ^ 0 = "; 0 ^ 0</syntaxhighlight>
 
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
<syntaxhighlight lang="qbasic">PRINT "0 ^ 0 ="; 0 ^ 0</syntaxhighlight>
 
==={{header|Run BASIC}}===
{{works with|Just BASIC}}
{{works with|Liberty BASIC}}
<syntaxhighlight lang="lb">print "0 ^ 0 = "; 0 ^ 0</syntaxhighlight>
 
==={{header|True BASIC}}===
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">PRINT "0 ^ 0 ="; 0 ^ 0
END</syntaxhighlight>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
<syntaxhighlight lang="xbasic">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</syntaxhighlight>
 
==={{header|ZX Spectrum Basic}}===
<syntaxhighlight lang="zxbasic">PRINT 0↑0</syntaxhighlight>
 
{{out}}
<pre>
1
 
0 OK, 0:1
</pre>
 
=={{header|BBC BASIC}}==
<syntaxhighlight lang="bbcbasic"> PRINT 0^0</syntaxhighlight>
 
{{out}}
<pre>
1
</pre>
 
=={{header|Bc}}==
<syntaxhighlight lang="bc">
0 ^ 0
</syntaxhighlight>
{{out}}
1
 
=={{header|Befunge}}==
'''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).
 
<syntaxhighlight lang="befunge">"PDPF"4#@(0F0FYP)@</syntaxhighlight>
 
{{out}}
<pre>1.000000</pre>
 
=={{header|Binary Lambda Calculus}}==
 
In lambda calculus, <code>\n. n n</code> is a function mapping a Church numeral n to the Church numeral n^n. The following BLC program computes this for n=0 by using its empty input as a Church numeral (since nil coincides with Church numeral 0), and outputting in unary (i.e as a string of 0^0 1s), as generated from https://github.com/tromp/AIT/blob/master/rosetta/exp00.lam :
 
<pre>0001010110100000010110111011010</pre>
 
Output:
 
<pre>1</pre>
 
=={{header|BQN}}==
BQN doesn't specify the details of arithmetic functions; existing implementations use IEEE doubles and the <code>pow</code> function, giving a result of 1.
<syntaxhighlight lang="bqn">0⋆0</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Bracmat}}==
<syntaxhighlight lang="bracmat">0^0</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Burlesque}}==
<syntaxhighlight lang="blsq">
blsq ) 0.0 0.0?^
1.0
blsq ) 0 0?^
1
</syntaxhighlight>
 
=={{header|C}}==
{{works with|C99}}
This example uses the standard <code>pow</code> function in the math library.
0^0 is given as 1.
<syntaxhighlight lang="c">#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;
}</syntaxhighlight>
}
</lang>
 
{{out}}
<pre>
0 ^ 0 = 1.000000
0+0i ^ 0+0i = nan+nani
</pre>
 
=={{header|C sharp|C#}}==
<syntaxhighlight lang="csharp">using System;
 
namespace ZeroToTheZeroeth
{
class Program
{
static void Main(string[] args)
{
double k = Math.Pow(0, 0);
Console.Write("0^0 is {0}", k);
}
}
}</syntaxhighlight>
 
{{out}}
<pre>
0^0 is 1
</pre>
 
=={{header|C++}}==
<syntaxhighlight lang="cpp">#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;
}</syntaxhighlight>
 
{{out}}
<pre>
0 ^ 0 = 1
0+0i ^ 0+0i = (nan,nan)
</pre>
 
=={{header|Caché ObjectScript}}==
<syntaxhighlight lang="caché objectscript">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</syntaxhighlight>
 
{{out}}<pre>SAMPLES>do ^ZEROPOW
 
0 to the 0th power (wrong): 0
0 to the 0th power (right): 1 </pre>
 
=={{header|Clojure}}==
<pre>
user=> (use 'clojure.math.numeric-tower)
user=> (expt 0 0)
1
 
; alternative java-interop route:
user=> (Math/pow 0 0)
1.0
</pre>
 
=={{header|CLU}}==
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.
 
<syntaxhighlight lang="clu">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</syntaxhighlight>
{{out}}
<pre>integer 0**0: 1
real 0**0: 1.0</pre>
 
=={{header|COBOL}}==
<syntaxhighlight lang="cobol">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.</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|ColdFusion}}==
=== Classic tag based CFML ===
<syntaxhighlight lang="cfm">
<cfset zeroPowerTag = 0^0>
<cfoutput>"#zeroPowerTag#"</cfoutput>
</syntaxhighlight>
{{Output}}
<pre>
"1"
</pre>
 
=== Script Based CFML ===
<syntaxhighlight lang="cfm"><cfscript>
zeroPower = 0^0;
writeOutput( zeroPower );
</cfscript></syntaxhighlight>
{{Output}}
<pre>
1
</pre>
 
=={{header|Commodore BASIC}}==
 
Commodore computers use the up arrow key <span style="font-size: 140%; line-height: 50%;">&uarr;</span> as the exponent operator.
 
{{out}}
<pre>ready.
print 0&uarr;0
1
 
ready.
&#9608;</pre>
 
 
=={{header|Common Lisp}}==
<pre>> (expt 0 0)
1</pre>
 
=={{header|Crystal}}==
<syntaxhighlight lang="crystal">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}"</syntaxhighlight>
 
{{Output}}
<pre>Int32: 1
Negative Int32: 1
Float32: 1.0
Negative Float32: 1.0</pre>
 
=={{header|D}}==
<langsyntaxhighlight lang="d">void main() {
import std.stdio, std.math, std.bigint, std.complex;
 
Line 49 ⟶ 465:
writeln("BigInt: ", 0.BigInt ^^ 0);
writeln("Complex: ", complex(0.0, 0.0) ^^ 0);
}</langsyntaxhighlight>
{{out}}
<pre>Int: 1
Line 59 ⟶ 475:
BigInt: 1
Complex: 1+0i</pre>
 
=={{header|Dart}}==
<syntaxhighlight lang="dart">import 'dart:math';
 
void main() {
var resul = pow(0, 0);
print("0 ^ 0 = $resul");
}</syntaxhighlight>
{{out}}
<pre>0 ^ 0 = 1</pre>
 
=={{header|Dc}}==
<syntaxhighlight lang="dc">0 0^p
</syntaxhighlight>
{{Output}}
<pre>
1
</pre>
 
=={{header|Delphi}}==
See [https://www.rosettacode.org/wiki/Zero_to_the_zero_power#Pascal Pascal].
 
=={{header|EasyLang}}==
 
<syntaxhighlight lang="text">print pow 0 0</syntaxhighlight>
 
=={{header|EchoLisp}}==
<syntaxhighlight lang="scheme">
;; 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
</syntaxhighlight>
 
=={{header|Eiffel}}==
<syntaxhighlight lang="eiffel">print (0^0)</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Elena}}==
ELENA 6.x
<syntaxhighlight lang="elena">import extensions;
public program()
{
console.printLine("0^0 is ",0.power(0))
}</syntaxhighlight>
{{out}}
<pre>
0^0 is 0
</pre>
 
=={{header|Elixir}}==
Elixir uses Erlang's <code>:math</code> for power operations and can handle zero to the zero power.
<syntaxhighlight lang="elixir">
:math.pow(0,0)
</syntaxhighlight>
 
{{out}}
1.0
=={{header|Emacs Lisp}}==
<syntaxhighlight lang="lisp">(expt 0 0)</syntaxhighlight>
{{out}}
1
 
=={{header|EMal}}==
<syntaxhighlight lang="emal">
writeLine(0 ** 0) # an integer
writeLine(0.0 ** 0.0) # a real
</syntaxhighlight>
{{out}}
<pre>
1
1.0
</pre>
 
=={{header|ERRE}}==
<syntaxhighlight lang="erre">
.....
PRINT(0^0)
.....
</syntaxhighlight>
{{out}}
<pre> 1
</pre>
 
=={{header|F_Sharp|F#}}==
In the REPL:
<pre>> let z = 0.**0.;;
 
val z : float = 1.0</pre>
 
=={{header|Factor}}==
<syntaxhighlight lang="factor">USING: math.functions.private ; ! ^complex
0 0 ^
C{ 0 0 } C{ 0 0 } ^complex</syntaxhighlight>
{{out}}
<pre>--- Data stack:
NAN: 8000000000000
C{ NAN: 8000000000000 NAN: 8000000000000 }</pre>
 
=={{header|Falcon}}==
'''VBA/Python programmer's approach not sure if it's the most falconic way'''
<syntaxhighlight lang="falcon">
/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */
 
x = 0
y = 0
z = x**y
> "z=", z
 
</syntaxhighlight>
{{out}}
<pre>
z=1
[Finished in 0.2s]
</pre>
 
=={{header|Fermat}}==
<syntaxhighlight lang="fermat">0^0</syntaxhighlight>
{{out}}<pre>1</pre>
 
=={{header|Forth}}==
<syntaxhighlight lang="forth">0e 0e f** f.</syntaxhighlight>
 
{{out}}
<pre>1.</pre>
 
Of course in an embedded program we would be tempted to "pre-calculate" the answer :-)
 
<syntaxhighlight lang="forth">: ^0 DROP 1 ;</syntaxhighlight>
 
{{Output}}
<pre>
0 ^0 . 1 ok
</pre>
 
=={{header|Fortran}}==
 
<syntaxhighlight lang="fortran">
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
</syntaxhighlight>
{{out}}
<pre>
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)
</pre>
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
Print "0 ^ 0 ="; 0 ^ 0
Sleep</syntaxhighlight>
 
{{out}}
<pre>
0 ^ 0 = 1
</pre>
 
=={{header|Frink}}==
<syntaxhighlight lang="frink">println[0^0]</syntaxhighlight>
 
{{out}}
<pre>
1
</pre>
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">window 1
 
print 0^0
 
HandleEvents</syntaxhighlight>
Output:
<pre>
1
</pre>
 
=={{header|Gambas}}==
'''[https://gambas-playground.proko.eu/?gist=7d505dbe89227e9b4423f92ef12d6829 Click this link to run this code]'''
<syntaxhighlight lang="gambas">Public Sub Main()
 
Print 0 ^ 0
 
End</syntaxhighlight>
Output:
<pre>
1
</pre>
 
=={{header|GAP}}==
<syntaxhighlight lang="gap">0^0;</syntaxhighlight>
{{out}}<pre>1</pre>
 
=={{header|Go}}==
Go does not have an exponentiation operator but has functions in the standard library for three types, float64, complex128, and big.Int. The functions for float64 and big.Int are documented to return 1. The function for complex128 does not have the special case documented.
As of Go 1.3, all are documented to return 1.
<lang go>package main
<syntaxhighlight lang="go">package main
 
import (
Line 76 ⟶ 702:
fmt.Println("big integer:", b.Exp(&b, &b, nil))
fmt.Println("complex: ", cmplx.Pow(0, 0))
}</langsyntaxhighlight>
{{out}}
<pre>
float64: 1
big integer: 1
complex: (01+0i)
</pre>
 
=={{header|Golfscript}}==
<syntaxhighlight lang="golfscript">0 0?</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Groovy}}==
{{trans|Java}}
Test:
<syntaxhighlight lang="groovy">println 0**0</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|GW-BASIC}}==
<syntaxhighlight lang="gwbasic">PRINT 0^0</syntaxhighlight>
{{out}}<pre>1</pre>
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import Data.Complex ( Complex((:+)) )
 
main =:: doIO ()
main = mapM_ print $ 0 ^ 0[
print $ 0. 0 ^ 0,
print $ 0.0 ^^ 0,
print $ 0 **^^ 0,
print $ (0 :+ 0) ^** 0</lang>,
(0 :+ 0) ^ 0,
(0 :+ 0) ** (0 :+ 0)
]</syntaxhighlight>
{{out}}
<pre>1
1
1.0
1.0
1.0
1.0 :+ 0.0
1.0 :+ 0.0</pre>
 
=={{header|HolyC}}==
<syntaxhighlight lang="holyc">F64 a = 0 ` 0;
Print("0 ` 0 = %5.3f\n", a);</syntaxhighlight>
 
{{out}}
<pre>
0 ` 0 = 1.000
</pre>
 
=={{header|Icon}} and {{header|Unicon}}==
 
"Works" in both languages:
<syntaxhighlight lang="unicon">procedure main()
write(0^0)
end</syntaxhighlight>
 
{{out}}
<pre>
->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
->
</pre>
 
=={{header|J}}==
<langsyntaxhighlight lang="j"> 0 ^ 0
1</langsyntaxhighlight>
 
Note also that this is the multiplicative identity (which means that it's consistent with <code>1*0</code> representing <code>0^1</code> and with <code>1*0*0</code> representing <code>0^2</code> and with <code>1*0*0*0</code> representing <code>0^3</code> and with <code>1*2*2*2</code> representing <code>2^3</code> and so on. Also, this is the result of finding the product of an empty list:
 
<syntaxhighlight lang="J"> */''
1</syntaxhighlight>
 
(In <code><nowiki>*/''</nowiki></code> 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.)
 
=={{header|Java}}==
<langsyntaxhighlight lang="java">System.out.println(Math.pow(0, 0));</langsyntaxhighlight>
{{out}}
<pre>1.0</pre>
 
=={{header|JavaScript}}==
===Math.pow===
{{Works with|Node.js}}
In interactive mode:
<syntaxhighlight lang="javascript">> Math.pow(0, 0);
1</syntaxhighlight>
===exponentiation operator (**)===
<syntaxhighlight lang="javascript">> 0**0
1</syntaxhighlight>
 
=={{header|jq}}==
{{works with|jq|1.5}}
'''Also works with gojq and fq'''
<pre>
$ jq -n 'pow(0;0)'
1
</pre>
It is also worth noting that in jq, gojq, and fq, `pow(0; infinite)` yields 0.
 
=={{header|Jsish}}==
<syntaxhighlight lang="javascript">puts(Math.pow(0,0));</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Julia}}==
Try all combinations of complex, float, rational, integer and boolean.
<syntaxhighlight lang="julia">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</syntaxhighlight>
 
{{out}}
<pre> 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)</pre>
 
=={{header|K}}==
<syntaxhighlight lang="k">
0^0
1.0
</syntaxhighlight>
 
=={{header|Klingphix}}==
<syntaxhighlight lang="klingphix">:mypower
dup not (
[ drop sign dup 0 equal [ drop 1 ] if ]
[ power ]
) if
;
0 0 mypower print nl
 
"End " input</syntaxhighlight>
{{out}}
<pre>1
End</pre>
 
=={{header|Kotlin}}==
<syntaxhighlight lang="kotlin">import kotlin.math.pow
 
fun main() {
println(0.0.pow(0))
}</syntaxhighlight>
 
{{out}}
<pre>
1.0
</pre>
 
=={{header|Lambdatalk}}==
<syntaxhighlight lang="scheme">
{pow 0 0}
-> 1
{exp 0 0}
-> 1
</syntaxhighlight>
 
=={{header|LDPL}}==
<syntaxhighlight lang="ldpl">data:
x is number
 
procedure:
raise 0 to 0 in x
display x lf
</syntaxhighlight>
{{out}}
<pre>
1
</pre>
 
=={{header|Liberty BASIC}}==
<syntaxhighlight lang="lb">
'********
print 0^0
'********
</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Locomotive Basic}}==
 
<syntaxhighlight lang="locobasic">print 0🠅0</syntaxhighlight>
{{out}}
<pre> 1</pre>
 
=={{header|Lua}}==
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.
<syntaxhighlight lang="lua">print(0^0)</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|M2000 Interpreter}}==
M2000 use ** and ^ for power.
<syntaxhighlight lang="m2000 interpreter">
Module Checkit {
x=0
y=0
Print x**y=1, x^y=1 ' True True
}
Checkit
</syntaxhighlight>
 
=={{header|Maple}}==
<syntaxhighlight lang="maple">0^0</syntaxhighlight>
{{out}}
<pre>1</pre>
 
However, for consistency with IEEE-754 numerics, we also have a NaN result for the equivalent floating-point exponentiation:
<syntaxhighlight lang="maple">0^0.0</syntaxhighlight>
{{out}}
<pre>Float(undefined)</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang="mathematica">0^0</syntaxhighlight>
{{out}}
<pre>Indeterminate</pre>
 
=={{header|MATLAB}} / {{header|Octave}}==
<syntaxhighlight lang="matlab">0^0
complex(0,0)^0</syntaxhighlight>
{{out}}
<pre>1
1</pre>
=={{header|Maxima}}==
<syntaxhighlight lang="maxima">0^0;</syntaxhighlight>
{{out}}<pre> 0
expt: undefined: 0</pre>
 
=={{header|Mercury}}==
<syntaxhighlight lang="mercury">:- 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.</syntaxhighlight>
{{out}}
<pre> int.pow(0, 0) = 1
integer.pow(zero, zero) = 1
float.pow(0.0, 0) = 1.0</pre>
 
=={{header|Microsoft Small Basic}}==
<syntaxhighlight lang="smallbasic">TextWindow.WriteLine(Math.Power(0,0))</syntaxhighlight>
{{out}}<pre>1</pre>
 
=={{header|min}}==
{{works with|min|0.19.3}}
<syntaxhighlight lang="min">0 0 pow puts</syntaxhighlight>
{{out}}
<pre>
1.0
</pre>
 
=={{header|MiniScript}}==
<syntaxhighlight lang="miniscript">print "The result of zero to the zero power is " + 0^0</syntaxhighlight>
{{out}}
<pre>
The result of zero to the zero power is 1
</pre>
 
=={{header|МК-61/52}}==
<syntaxhighlight lang="text">Сx ^ x^y С/П</syntaxhighlight>
 
The result is error message.
 
=={{header|Nanoquery}}==
<syntaxhighlight lang="nanoquery">println 0^0</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Neko}}==
Neko uses the C math library for exponentiation, Zero to the zero in math.pow(x, y) is treated as being 1.
 
<syntaxhighlight lang="actionscript">/**
Zero to the zeroth power, in Neko
*/
 
var math_pow = $loader.loadprim("std@math_pow", 2)
 
$print(math_pow(0, 0), "\n")</syntaxhighlight>
 
{{out}}
<pre>prompt$ nekoc zero-to-the-zero.neko
prompt$ neko zero-to-the-zero.n
1</pre>
 
=={{header|NetRexx}}==
<syntaxhighlight lang="netrexx">x=0
Say '0**0='||x**x</syntaxhighlight>
{{out}}
<pre>0**0=1</pre>
 
=={{header|NewLISP}}==
<syntaxhighlight lang="newlisp">(pow 0 0)</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Nial}}==
 
Create an exponentiation table for all type combinations (of integer <code>0</code>, float <code>0.0</code> and boolean <code>o</code>):
 
<syntaxhighlight lang="nial"> 0 0.0 o outer power 0 0.0 o
+--+--+--+
| 1|1.| 1|
+--+--+--+
|1.|1.|1.|
+--+--+--+
| 1|1.| 1|
+--+--+--+</syntaxhighlight>
 
=={{header|Nim}}==
<syntaxhighlight lang="nim">import math
 
echo pow(0.0, 0.0) # Floating point exponentiation.
echo 0 ^ 0 # Integer exponentiation.</syntaxhighlight>
{{out}}
<pre>1.0
1</pre>
 
=={{header|OCaml}}==
Line 124 ⟶ 1,081:
</pre>
 
=={{header|Perl 6Oforth}}==
 
Translation of REXX.
<syntaxhighlight lang="oforth">0 0 pow println</syntaxhighlight>
<lang perl 6>say '0 ** 0 (zero to the zeroth power) ───► ', 0**0</lang>{{out}}
 
{{out}}
<pre>
1
0 ** 0 (zero to the zeroth power) ───► 1
</pre>
 
=={{header|Ol}}==
<syntaxhighlight lang="scheme">
(print "0^0: " (expt 0 0))
(print "0.0^0: " (expt (inexact 0) 0))
</syntaxhighlight>
{{out}}
<pre>
0^0: 1
0.0^0: 1
</pre>
 
=={{header|ooRexx}}==
<syntaxhighlight lang="oorexx">/**********************************************************************
* 21.04.2014 Walter Pachl
**********************************************************************/
Say 'rxCalcpower(0,0) ->' rxCalcpower(0,0)
Say '0**0 ->' 0**0
::requires rxmath library</syntaxhighlight>
{{out}}
<pre>
rxCalcpower(0,0) -> 1
0**0 -> 1
</pre>
 
 
=={{header|Openscad}}==
<syntaxhighlight lang="openscad">echo (0^0);</syntaxhighlight>
 
 
=={{header|PARI/GP}}==
0 raised to the power of exact 0 is 1, but 0 cannot be raised to the power of an inexact 0:
<syntaxhighlight lang="parigp">0^0
0.^0
0^0.</syntaxhighlight>
{{out}}
<pre>%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</pre>
 
=={{header|Pascal}}==
{{works with|Free Pascal}} {{Libheader|math}}
<syntaxhighlight lang="pascal">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.</syntaxhighlight>
;output:
<pre>0.0 ^ 0 :1.00 0.0 ^ 0.0 :1.00</pre>
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">print 0 ** 0, "\n";
 
use Math::Complex;
 
print cplx(0,0) ** cplx(0,0), "\n";</syntaxhighlight>
{{out}}
<pre>
1
1
</pre>
 
=={{header|Phix}}==
{{libheader|Phix/basics}}
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">power</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"0.8.4"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- (now fixed/crashes on earlier versions)</span>
<span style="color: #008080;">include</span> <span style="color: #004080;">complex</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #004080;">complex</span> <span style="color: #000000;">a</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">complex_new</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">),</span>
<span style="color: #000000;">b</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">complex_power</span><span style="color: #0000FF;">(</span><span style="color: #000000;">a</span><span style="color: #0000FF;">,</span><span style="color: #000000;">a</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">sa</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">complex_sprint</span><span style="color: #0000FF;">(</span><span style="color: #000000;">a</span><span style="color: #0000FF;">,</span><span style="color: #004600;">true</span><span style="color: #0000FF;">),</span>
<span style="color: #000000;">sb</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">complex_sprint</span><span style="color: #0000FF;">(</span><span style="color: #000000;">b</span><span style="color: #0000FF;">,</span><span style="color: #004600;">true</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s ^ %s = %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">sa</span><span style="color: #0000FF;">,</span><span style="color: #000000;">sa</span><span style="color: #0000FF;">,</span><span style="color: #000000;">sb</span><span style="color: #0000FF;">})</span>
<!--</syntaxhighlight>-->
{{out}}
<pre>
1
0+0i ^ 0+0i = 1+0i
</pre>
 
=={{header|Phixmonti}}==
<syntaxhighlight lang="phixmonti">def mypower
dup not if
. sign dup 0 == if . 1 endif
else
power
endif
enddef
 
0 0 mypower print</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|PHP}}==
<syntaxhighlight lang="php"><?php
echo pow(0,0);
echo 0 ** 0; // PHP 5.6+ only
?></syntaxhighlight>
{{out}}
<pre>
1
1
</pre>
 
=={{header|PicoLisp}}==
<syntaxhighlight lang="picolisp">
(** 0 0)
</syntaxhighlight>
{{out}}
1
 
=={{header|Pike}}==
<syntaxhighlight lang="pike">write( pow(0, 0) +"\n" );</syntaxhighlight>
{{Out}}
<pre>
1
</pre>
 
=={{header|PL/I}}==
<syntaxhighlight lang="pli"> 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;</syntaxhighlight>
{{out}}
<pre>
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
</pre>
 
=={{header|Plain English}}==
<syntaxhighlight lang="plainenglish">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.</syntaxhighlight>
{{out}}
<pre>
1
</pre>
 
=={{header|PowerShell}}==
 
<syntaxhighlight lang="powershell">Write-Host "0 ^ 0 = " ([math]::pow(0,0))</syntaxhighlight>
 
Output :
 
<pre>
0 ^ 0 = 1
</pre>
 
=={{header|PureBasic}}==
<syntaxhighlight lang="purebasic">
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
</syntaxhighlight>
 
{{out}}
<pre>
Zero to the zero power is 1
</pre>
 
=={{header|Pyret}}==
<syntaxhighlight lang="pyret">num-expt(0, 0)</syntaxhighlight>
{{out}}
1
 
=={{header|Python}}==
===Python3===
<lang python>>>> from decimal import Decimal
<syntaxhighlight lang="python">>> from fractionsdecimal import FractionDecimal
from fractions import Fraction
>>> for n in (Decimal(0), Fraction(0, 1), complex(0), float(0), int(0)):
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}')</syntaxhighlight>
{{out}}
<pre> 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>'</pre>
 
===Python2===
<syntaxhighlight lang="python">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
Line 143 ⟶ 1,365:
except:
n2 = '<Raised exception>'
print('%8s: ** -> %r; pow -> %r' % (n.__class__.__name__, n1, n2))</syntaxhighlight>
{{out}}
 
<pre>
Decimal: ** -> '<Raised exception>'; pow -> '<Raised exception>'
Fraction: ** -> Fraction(1, 1); pow -> Fraction(1, 1)
Line 151 ⟶ 1,373:
float: ** -> 1.0; pow -> 1.0
int: ** -> 1; pow -> 1
>>> </langpre>
 
=={{header|QB64}}==
<syntaxhighlight lang="qb64">Print 0 ^ 0</syntaxhighlight>
{{out}}
<pre>1</pre>
Alternatively:
<syntaxhighlight lang="qb64">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&&</syntaxhighlight>
{{out}}
NB: Values with 0 decimals are trimmed by Print's casting from number value to String.
<pre> 1
1
1
1
1
1
1</pre>
 
=={{header|Quackery}}==
As a dialogue in the Quackery shell.
 
<syntaxhighlight lang="quackery">/O> 0 0 **
...
 
Stack: 1
</syntaxhighlight>
 
=={{header|R}}==
<syntaxhighlight lang="rsplus">print(0^0)</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Racket}}==
 
<syntaxhighlight lang="racket">#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))))</syntaxhighlight>
 
{{out}}
<pre>(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</pre>
 
=={{header|Raku}}==
(formerly Perl 6)
 
{{works with|Rakudo|2018.03}}
<syntaxhighlight lang="raku" line>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($_,$_);
}</syntaxhighlight>
 
{{out}}
<pre>
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
</pre>
 
=={{header|Red}}==
Shown using the operator, the function, and the <code>math</code> mini-DSL that uses the order of operations from mathematics:
<syntaxhighlight lang="rebol">Red[]
print 0 ** 0
print power 0 0
print math [0 ** 0]</syntaxhighlight>
{{out}}
<pre>
1
1
1
</pre>
 
=={{header|Relation}}==
<syntaxhighlight lang="relation">
echo pow(0,0)
// 1
</syntaxhighlight>
 
=={{header|REXX}}==
<langsyntaxhighlight lang="rexx">/*REXX program shows the results of raising zero to the zeroth power.*/
say '0 ** 0 (zero to the zeroth power) ───► ' 0**0</langsyntaxhighlight>
<br>using PC/REXX
<br>using Personal REXX
<br>using REGINA
<br>using ooRexx
'''output'''
{{out}}
<pre>
0 ** 0 (zero to the zeroth power) ───► 1
</pre>
 
using R4 <br>
{{out}}
'''output'''
<pre>
Error 26 : Invalid whole number (SYNTAX)
Line 174 ⟶ 1,537:
</pre>
 
using ROO <br>
{{out}}
'''output'''
<pre>
Error 26 : Invalid whole number (SYNTAX)
Line 182 ⟶ 1,545:
Statement source: say '0 ** 0 (zero to the zeroth power) ───► ' 0**0
Statement context: C:\ZERO_TO0.REX, procedure: ZERO_TO0
</pre>
 
=={{header|Ring}}==
<syntaxhighlight lang="ring">
x = 0
y = 0
z = pow(x,y)
see "z=" + z + nl # z=1
</syntaxhighlight>
 
=={{header|RPL}}==
0 0 ^
====Output for HP-48G and older models====
1: 1
====Output for HP-49 and newer models====
1: ?
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">require 'bigdecimal'
 
[0, 0.0, Complex(0), Rational(0), BigDecimal("0")].each do |n|
printf "%10s: ** -> %s\n" % [n.class, n**n]
end</syntaxhighlight>
{{out}}
<pre>
Integer: ** -> 1
Float: ** -> 1.0
Complex: ** -> 1+0i
Rational: ** -> 1/1
BigDecimal: ** -> 0.1e1
</pre>
 
=={{header|Rust}}==
<syntaxhighlight lang="rust">fn main() {
println!("{}",0u32.pow(0));
}</syntaxhighlight>
 
{{out}}
<pre>1</pre>
 
=={{header|S-lang}}==
<syntaxhighlight lang="s-lang">print(0^0);</syntaxhighlight>
{{out}}
<pre>1.0</pre>
 
=={{header|Scala}}==
{{libheader|Scala}}<syntaxhighlight lang="scala"> assert(math.pow(0, 0) == 1, "Scala blunder, should go back to school !")</syntaxhighlight>
 
=={{header|Scheme}}==
<syntaxhighlight lang="scheme">(display (expt 0 0)) (newline)
(display (expt 0.0 0.0)) (newline)
(display (expt 0+0i 0+0i)) (newline)</syntaxhighlight>
{{out}}
<pre>1
1.0
1.0</pre>
 
=={{header|Seed7}}==
<syntaxhighlight lang="seed7">$ 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;
</syntaxhighlight>
 
{{out}}
<pre>
0 ** 0 = 1
0.0 ** 0 = 1.0
0.0 ** 0.0 = 1.0
0.0+0i ** 0 = 1.0+0.0i
</pre>
 
=={{header|SenseTalk}}==
<syntaxhighlight lang="sensetalk">set a to 0
set b to 0
 
put a to the power of b
// Prints: 1</syntaxhighlight>
 
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">[0, Complex(0, 0)].each {|n|
say n**n
}</syntaxhighlight>
{{out}}
<pre>
1
1
</pre>
 
Taking the 0'th root of a number and raising it back to the zero power, we also get a 1:
 
<syntaxhighlight lang="ruby">say 0.root(0).pow(0) # => 1
say ((0**(1/0))**0) # => 1</syntaxhighlight>
 
=={{header|Sinclair ZX81 BASIC}}==
<syntaxhighlight lang="basic">PRINT 0**0</syntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Smalltalk}}==
 
<syntaxhighlight lang="smalltalk">
0 raisedTo: 0
0.0 raisedTo: 0.0
</syntaxhighlight>
{{out}}
<pre>
1
1.0
</pre>
 
=={{header|smart BASIC}}==
<syntaxhighlight lang="qbasic">PRINT 0^0</syntaxhighlight>
 
{{out}}
<pre>
1
</pre>
 
 
=={{header|SNOBOL4}}==
<syntaxhighlight lang="snobol4"> OUTPUT = (0 ** 0)
END</syntaxhighlight>
 
 
=={{header|SQL}}==
<syntaxhighlight lang="sql">
SQL> select power(0,0) from dual;
</syntaxhighlight>
{{out}}
<pre>
POWER(0,0)
----------
1
</pre>
 
Line 190 ⟶ 1,694:
val it = 1.0 : real
</pre>
 
=={{header|Stata}}==
<syntaxhighlight lang="stata">. display 0^0
1</syntaxhighlight>
 
=={{header|Swift}}==
<syntaxhighlight lang="swift">import Darwin
print(pow(0.0,0.0))</syntaxhighlight>
{{out}}
<pre>1.0</pre>
 
=={{header|Symsyn}}==
<syntaxhighlight lang="symsyn">
(0^0) []
</syntaxhighlight>
{{out}}
<pre> 1 </pre>
 
=={{header|Tcl}}==
Interactively…
<langsyntaxhighlight lang="tcl">% expr 0**0
1
% expr 0.0**0.0
1.0</langsyntaxhighlight>
 
=={{header|TI SR-56}}==
<syntaxhighlight lang="text">0 Yx 0 =</syntaxhighlight>
 
{{out}}
<pre> 1 </pre>
 
=={{header|TI-83_BASIC}}==
<syntaxhighlight lang="tibasic">0^0</syntaxhighlight>
{{out}}
<pre>ERROR:DOMAIN</pre>
 
=={{header|uBasic/4tH}}==
<syntaxhighlight lang="text">Print 0^0</syntaxhighlight>
{{out}}
<pre>1
 
0 OK, 0:9</pre>
 
=={{header|Ursa}}==
Cygnus/X Ursa is written in Java, and as a result returns 1.0 when raising 0 to the 0.
<syntaxhighlight lang="ursa">> out (pow 0 0) endl console
1.0</syntaxhighlight>
 
=={{header|VBA}}==
<syntaxhighlight lang="vb">Public Sub zero()
x = 0
y = 0
z = 0 ^ 0
Debug.Print "z ="; z
End Sub</syntaxhighlight>{{out}}
<pre>z = 1</pre>
 
=={{header|VBScript}}==
<syntaxhighlight lang="vb">WScript.Echo 0 ^ 0</syntaxhighlight>
{{Out}}
<pre>1</pre>
 
 
=={{header|Verilog}}==
<syntaxhighlight lang="verilog">module main;
initial begin
$display("0 ^ 0 = ", 0**0);
$finish ;
end
endmodule</syntaxhighlight>
{{out}}
<pre>0 ^ 0 = 1</pre>
 
 
=={{header|Visual Basic .NET}}==
<syntaxhighlight lang="vbnet">Module Program
Sub Main()
Console.Write(0^0)
End Sub
End Module</syntaxhighlight>
 
{{out}}
<pre>1</pre>
 
=={{header|V (Vlang)}}==
<syntaxhighlight lang="go">// 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))
}</syntaxhighlight>
{{out}}<pre>prompt$ v run rosetta/zero-to-the-zero-power.v
1.</pre>
 
=={{header|Wren}}==
<syntaxhighlight lang="wren">System.print(0.pow(0))</syntaxhighlight>
 
{{out}}
<pre>
1
</pre>
 
=={{header|XLISP}}==
<syntaxhighlight lang="scheme">XLISP 3.3, September 6, 2002 Copyright (c) 1984-2002, by David Betz
[1] (expt 0 0)
 
1
[2] </syntaxhighlight>
 
=={{header|XPL0}}==
<syntaxhighlight lang="xpl0">RlOut(0, Pow(0., 0.))</syntaxhighlight>
{{out}}
<pre> 1.00000</pre>
 
=={{header|Zig}}==
<syntaxhighlight lang="zig">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)});
}</syntaxhighlight>
{{out}}
<pre>0^0 = 1.00000000</pre>
 
=={{header|zkl}}==
<syntaxhighlight lang="zkl">(0.0).pow(0) //--> 1.0
var BN=Import("zklBigNum"); // big ints
BN(0).pow(0) //--> 1</syntaxhighlight>
56

edits