Zero to the zero power: Difference between revisions

m
(Add Zig)
 
(32 intermediate revisions by 21 users not shown)
Line 2:
[[Category:Simple]]
{{omit from|6502 Assembly|There is no built in multiplication, let alone exponentiation. Thus the outcome is decided by the programmer not the language.}}
{{omit from|8080 Assembly|See 6502 Assembly.}}
{{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   (with other computer programming languages)  
<br>when &nbsp; ''raising zero to the zeroth power'': &nbsp; &nbsp; <b><big>0<sup>0</sup></big></b>
Line 25 ⟶ 29:
 
;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>.
Line 33 ⟶ 37:
 
=={{header|11l}}==
<syntaxhighlight lang ="11l">print(0 ^ 0)</langsyntaxhighlight>
 
{{out}}
Line 41 ⟶ 45:
 
=={{header|8th}}==
<langsyntaxhighlight lang="forth">
0 0 ^ .
</syntaxhighlight>
</lang>
{{out}}
1
Line 52 ⟶ 56:
=={{header|Action!}}==
{{libheader|Action! Tool Kit}}
<langsyntaxhighlight Actionlang="action!">INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit
 
PROC Main()
Line 65 ⟶ 69:
PrintR(z) Print("=")
PrintRE(res)
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Zero_to_the_zero_power.png Screenshot from Atari 8-bit computer]
Line 73 ⟶ 77:
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="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;
Line 104 ⟶ 108:
Put (LLF ** Zero); New_Line;
end Test5;
</syntaxhighlight>
</lang>
{{out}}
<pre>Integer 0^0 = 1
Line 116 ⟶ 120:
=={{header|ALGOL 68}}==
{{works with|ALGOL 68G|Any - tested with release 2.6.win32}}
<langsyntaxhighlight lang="algol68">print( ( 0 ^ 0, newline ) )
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 124 ⟶ 128:
 
=={{header|APL}}==
<langsyntaxhighlight lang="apl"> 0*0
1</langsyntaxhighlight>
 
=={{header|AppleScript}}==
<syntaxhighlight lang ="applescript"> return 0 ^ 0</langsyntaxhighlight>
 
{{output}}
<syntaxhighlight lang ="applescript">1.0</langsyntaxhighlight>
 
=={{header|Applesoft BASIC}}==
Line 141 ⟶ 145:
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">print 0 ^ 0
print 0.0 ^ 0</langsyntaxhighlight>
 
{{out}}
Line 150 ⟶ 154:
 
=={{header|Asymptote}}==
<langsyntaxhighlight Asymptotelang="asymptote">write("0 ^ 0 = ", 0 ** 0);</langsyntaxhighlight>
 
=={{header|AutoHotkey}}==
<syntaxhighlight lang AutoHotkey="autohotkey">MsgBox % 0 ** 0</langsyntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f ZERO_TO_THE_ZERO_POWER.AWK
BEGIN {
Line 164 ⟶ 168:
exit(0)
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 171 ⟶ 175:
 
=={{header|BaCon}}==
<syntaxhighlight lang ="freebasic">PRINT POW(0, 0)</langsyntaxhighlight>
 
{{out}}
Line 179 ⟶ 183:
=={{header|BASIC}}==
==={{header|BASIC256}}===
<langsyntaxhighlight BASIC256lang="basic256">print "0 ^ 0 = "; 0 ^ 0</langsyntaxhighlight>
 
==={{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}}
<langsyntaxhighlight lang="qbasic">PRINT "0 ^ 0 ="; 0 ^ 0</langsyntaxhighlight>
 
==={{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}}
<langsyntaxhighlight lang="qbasic">PRINT "0 ^ 0 ="; 0 ^ 0
END</langsyntaxhighlight>
 
==={{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}}==
<langsyntaxhighlight lang="bbcbasic"> PRINT 0^0</langsyntaxhighlight>
 
{{out}}
Line 201 ⟶ 240:
 
=={{header|Bc}}==
<syntaxhighlight lang="bc">
<lang Bc>
0 ^ 0
</syntaxhighlight>
</lang>
{{out}}
1
Line 212 ⟶ 251:
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).
 
<langsyntaxhighlight lang="befunge">"PDPF"4#@(0F0FYP)@</langsyntaxhighlight>
 
{{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="bqn">0⋆0</langsyntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Bracmat}}==
<syntaxhighlight lang ="bracmat">0^0</langsyntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Burlesque}}==
<langsyntaxhighlight lang="blsq">
blsq ) 0.0 0.0?^
1.0
blsq ) 0 0?^
1
</syntaxhighlight>
</lang>
 
=={{header|C}}==
Line 240 ⟶ 289:
This example uses the standard <code>pow</code> function in the math library.
0^0 is given as 1.
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <math.h>
#include <complex.h>
Line 250 ⟶ 299:
printf("0+0i ^ 0+0i = %f+%fi\n", creal(c), cimag(c));
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 259 ⟶ 308:
 
=={{header|C sharp|C#}}==
<langsyntaxhighlight lang="csharp">using System;
 
namespace ZeroToTheZeroeth
Line 271 ⟶ 320:
}
}
}</langsyntaxhighlight>
 
{{out}}
Line 279 ⟶ 328:
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <iostream>
#include <cmath>
#include <complex>
Line 289 ⟶ 338:
std::pow(std::complex<double>(0),std::complex<double>(0)) << std::endl;
return 0;
}</langsyntaxhighlight>
 
{{out}}
Line 298 ⟶ 347:
 
=={{header|Caché ObjectScript}}==
<langsyntaxhighlight Cachélang="caché ObjectScriptobjectscript">ZEROPOW
// default behavior is incorrect:
set (x,y) = 0
Line 307 ⟶ 356:
w !,"0 to the 0th power (right): "_(x**y)
quit</langsyntaxhighlight>
 
{{out}}<pre>SAMPLES>do ^ZEROPOW
Line 329 ⟶ 378:
1 in my case could just be an implementation detail.
 
<langsyntaxhighlight lang="clu">start_up = proc ()
zz_int: int := 0 ** 0
zz_real: real := 0.0 ** 0.0
Line 336 ⟶ 385:
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</langsyntaxhighlight>
{{out}}
<pre>integer 0**0: 1
Line 342 ⟶ 391:
 
=={{header|COBOL}}==
<langsyntaxhighlight lang="cobol">identification division.
program-id. zero-power-zero-program.
data division.
Line 350 ⟶ 399:
compute n = 0**0.
display n upon console.
stop run.</langsyntaxhighlight>
{{out}}
<pre>1</pre>
Line 356 ⟶ 405:
=={{header|ColdFusion}}==
=== Classic tag based CFML ===
<langsyntaxhighlight lang="cfm">
<cfset zeroPowerTag = 0^0>
<cfoutput>"#zeroPowerTag#"</cfoutput>
</syntaxhighlight>
</lang>
{{Output}}
<pre>
Line 366 ⟶ 415:
 
=== Script Based CFML ===
<langsyntaxhighlight lang="cfm"><cfscript>
zeroPower = 0^0;
writeOutput( zeroPower );
</cfscript></langsyntaxhighlight>
{{Output}}
<pre>
Line 393 ⟶ 442:
 
=={{header|Crystal}}==
<langsyntaxhighlight 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}"</langsyntaxhighlight>
 
{{Output}}
Line 405 ⟶ 454:
 
=={{header|D}}==
<langsyntaxhighlight lang="d">void main() {
import std.stdio, std.math, std.bigint, std.complex;
 
Line 416 ⟶ 465:
writeln("BigInt: ", 0.BigInt ^^ 0);
writeln("Complex: ", complex(0.0, 0.0) ^^ 0);
}</langsyntaxhighlight>
{{out}}
<pre>Int: 1
Line 426 ⟶ 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}}==
<langsyntaxhighlight lang="dc">0 0^p
</syntaxhighlight>
</lang>
{{Output}}
<pre>
Line 440 ⟶ 499:
=={{header|EasyLang}}==
 
<syntaxhighlight lang="text">print pow 0 0</langsyntaxhighlight>
 
=={{header|EchoLisp}}==
<langsyntaxhighlight lang="scheme">
;; trying the 16 combinations
;; all return the integer 1
Line 451 ⟶ 510:
(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>
</lang>
 
=={{header|Eiffel}}==
<syntaxhighlight lang Eiffel="eiffel">print (0^0)</langsyntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|Elena}}==
ELENA 46.x
<langsyntaxhighlight lang="elena">import extensions;
public program()
{
console.printLine("0^0 is ",0.power:(0))
}</langsyntaxhighlight>
{{out}}
<pre>
Line 473 ⟶ 532:
=={{header|Elixir}}==
Elixir uses Erlang's <code>:math</code> for power operations and can handle zero to the zero power.
<syntaxhighlight lang="elixir">
<lang Elixir>
:math.pow(0,0)
</syntaxhighlight>
</lang>
 
{{out}}
1.0
=={{header|Emacs Lisp}}==
<syntaxhighlight lang Lisp="lisp">(expt 0 0)</langsyntaxhighlight>
{{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">
<lang ERRE>
.....
PRINT(0^0)
.....
</syntaxhighlight>
</lang>
{{out}}
<pre> 1
Line 501 ⟶ 571:
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: math.functions.private ; ! ^complex
0 0 ^
C{ 0 0 } C{ 0 0 } ^complex</langsyntaxhighlight>
{{out}}
<pre>--- Data stack:
Line 511 ⟶ 581:
=={{header|Falcon}}==
'''VBA/Python programmer's approach not sure if it's the most falconic way'''
<langsyntaxhighlight lang="falcon">
/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */
Line 520 ⟶ 590:
> "z=", z
 
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 528 ⟶ 598:
 
=={{header|Fermat}}==
<syntaxhighlight lang ="fermat">0^0</langsyntaxhighlight>
{{out}}<pre>1</pre>
 
=={{header|Forth}}==
<syntaxhighlight lang ="forth">0e 0e f** f.</langsyntaxhighlight>
 
{{out}}
Line 539 ⟶ 609:
Of course in an embedded program we would be tempted to "pre-calculate" the answer :-)
 
<langsyntaxhighlight Forthlang="forth">: ^0 DROP 1 ;</langsyntaxhighlight>
 
{{Output}}
Line 548 ⟶ 618:
=={{header|Fortran}}==
 
<syntaxhighlight lang="fortran">
<lang Fortran>
program zero
double precision :: i, j
Line 560 ⟶ 630:
write(*,*) 'When complex numbers are used, we have (0.0+0.0i)^(0.0+0.0i) = ', z1**z2
end program
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 569 ⟶ 639:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
Print "0 ^ 0 ="; 0 ^ 0
Sleep</langsyntaxhighlight>
 
{{out}}
Line 580 ⟶ 650:
 
=={{header|Frink}}==
<syntaxhighlight lang ="frink">println[0^0]</langsyntaxhighlight>
 
{{out}}
Line 589 ⟶ 659:
 
=={{header|FutureBasic}}==
<langsyntaxhighlight lang="futurebasic">window 1
include "ConsoleWindow"
 
print 0^0
 
</lang>
HandleEvents</syntaxhighlight>
Output:
<pre>
Line 601 ⟶ 671:
=={{header|Gambas}}==
'''[https://gambas-playground.proko.eu/?gist=7d505dbe89227e9b4423f92ef12d6829 Click this link to run this code]'''
<langsyntaxhighlight lang="gambas">Public Sub Main()
 
Print 0 ^ 0
 
End</langsyntaxhighlight>
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.
As of Go 1.3, all are documented to return 1.
<langsyntaxhighlight lang="go">package main
 
import (
Line 628 ⟶ 702:
fmt.Println("big integer:", b.Exp(&b, &b, nil))
fmt.Println("complex: ", cmplx.Pow(0, 0))
}</langsyntaxhighlight>
{{out}}
<pre>
Line 635 ⟶ 709:
complex: (1+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</langsyntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|GW-BASIC}}==
<syntaxhighlight lang ="gwbasic">PRINT 0^0</langsyntaxhighlight>
{{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,
print $ (0 :+ 0) **^ (0 :+ 0)</lang>,
(0 :+ 0) ** (0 :+ 0)
]</syntaxhighlight>
{{out}}
<pre>1
1
1.0
1.0
1.0
1.0 :+ 0.0
NaN1.0 :+ NaN0.0</pre>
</pre>
 
=={{header|HolyC}}==
<langsyntaxhighlight lang="holyc">F64 a = 0 ` 0;
Print("0 ` 0 = %5.3f\n", a);</langsyntaxhighlight>
 
{{out}}
Line 679 ⟶ 758:
 
"Works" in both languages:
<langsyntaxhighlight lang="unicon">procedure main()
write(0^0)
end</langsyntaxhighlight>
 
{{out}}
Line 697 ⟶ 776:
 
=={{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>
Line 709 ⟶ 795:
{{Works with|Node.js}}
In interactive mode:
<langsyntaxhighlight lang="javascript">> Math.pow(0, 0);
1</langsyntaxhighlight>
===exponentiation operator (**)===
<langsyntaxhighlight lang="javascript">> 0**0
1</langsyntaxhighlight>
 
=={{header|jq}}==
{{works with|jq|1.5}}
jq version 1.4 does not have a builtin "power" function. If it were to be defined
'''Also works with gojq and fq'''
using the exp and log builtins as 'log * y | exp', then 0 | power(0) would yield null, and therefore
<pre>
a definition that makes a special case of 0^0 should be considered, e.g.
$ jq -n 'pow(0;0)'
along the following lines:
1
<lang jq>def power(y): y as $y | if $y == 0 then 1 elif . == 0 then 0 else log * $y | exp end;</lang>
</pre>
 
It is also worth noting that in jq, gojq, and fq, `pow(0; infinite)` yields 0.
This definition will however be unsatisfactory for many purposes
because it does not maintain precision for integer values of the input (.) and y.
 
=={{header|Jsish}}==
<langsyntaxhighlight lang="javascript">puts(Math.pow(0,0));</langsyntaxhighlight>
{{out}}
<pre>1</pre>
Line 732 ⟶ 817:
=={{header|Julia}}==
Try all combinations of complex, float, rational, integer and boolean.
<langsyntaxhighlight Julialang="julia">using Printf
 
const types = (Complex, Float64, Rational, Int, Bool)
Line 740 ⟶ 825:
r = zb ^ ze
@printf("%10s ^ %-10s = %7s ^ %-7s = %-12s (%s)\n", Tb, Te, zb, ze, r, typeof(r))
end</langsyntaxhighlight>
 
{{out}}
Line 770 ⟶ 855:
 
=={{header|K}}==
<syntaxhighlight lang="k">
<lang K>
0^0
1.0
</syntaxhighlight>
</lang>
 
=={{header|Klingphix}}==
<langsyntaxhighlight Klingphixlang="klingphix">:mypower
dup not (
[ drop sign dup 0 equal [ drop 1 ] if ]
Line 785 ⟶ 870:
0 0 mypower print nl
 
"End " input</langsyntaxhighlight>
{{out}}
<pre>1
Line 791 ⟶ 876:
 
=={{header|Kotlin}}==
<syntaxhighlight lang="kotlin">import kotlin.math.pow
<lang scala>// version 1.0.6
 
fun main(args: Array<String>) {
println("0 ^ .0 = ${Math.pow(0.0, 0.0)}")
}</langsyntaxhighlight>
 
{{out}}
<pre>
0 ^ 0 = 1.0
</pre>
 
=={{header|Lambdatalk}}==
<syntaxhighlight lang="scheme">
<lang Scheme>
{pow 0 0}
-> 1
{exp 0 0}
-> 1
</syntaxhighlight>
</lang>
 
=={{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">
<lang lb>
'********
print 0^0
'********
</syntaxhighlight>
</lang>
{{out}}
<pre>1</pre>
Line 821 ⟶ 919:
=={{header|Locomotive Basic}}==
 
<syntaxhighlight lang ="locobasic">print 0🠅0</langsyntaxhighlight>
{{out}}
<pre> 1</pre>
Line 827 ⟶ 925:
=={{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="lua">print(0^0)</langsyntaxhighlight>
{{out}}
<pre>1</pre>
Line 833 ⟶ 931:
=={{header|M2000 Interpreter}}==
M2000 use ** and ^ for power.
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module Checkit {
x=0
Line 840 ⟶ 938:
}
Checkit
</syntaxhighlight>
</lang>
 
=={{header|Maple}}==
<syntaxhighlight lang Maple="maple">0^0</langsyntaxhighlight>
{{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="maple">0^0.0</langsyntaxhighlight>
{{out}}
<pre>Float(undefined)</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang Mathematica="mathematica">0^0</langsyntaxhighlight>
{{out}}
<pre>Indeterminate</pre>
 
=={{header|MATLAB}} / {{header|Octave}}==
<syntaxhighlight lang="matlab">0^0
<lang Matlab>0^0
complex(0,0)^0</langsyntaxhighlight>
{{out}}
<pre>1
1</pre>
=={{header|Maxima}}==
<syntaxhighlight lang ="maxima">0^0;</langsyntaxhighlight>
{{out}}<pre> 0
expt: undefined: 0</pre>
 
=={{header|Mercury}}==
<langsyntaxhighlight Mercurylang="mercury">:- module zero_to_the_zero_power.
:- interface.
 
Line 886 ⟶ 984:
io.format(" float.pow(0.0, 0) = %.1f\n", [f(pow(0.0, 0))], !IO).
 
:- end_module zero_to_the_zero_power.</langsyntaxhighlight>
{{out}}
<pre> int.pow(0, 0) = 1
Line 893 ⟶ 991:
 
=={{header|Microsoft Small Basic}}==
<langsyntaxhighlight lang="smallbasic">TextWindow.WriteLine(Math.Power(0,0))</langsyntaxhighlight>
{{out}}<pre>1</pre>
 
=={{header|min}}==
{{works with|min|0.19.3}}
<syntaxhighlight lang ="min">0 0 pow puts</langsyntaxhighlight>
{{out}}
<pre>
Line 905 ⟶ 1,003:
 
=={{header|MiniScript}}==
<langsyntaxhighlight MiniScriptlang="miniscript">print "The result of zero to the zero power is " + 0^0</langsyntaxhighlight>
{{out}}
<pre>
Line 912 ⟶ 1,010:
 
=={{header|МК-61/52}}==
<syntaxhighlight lang="text">Сx ^ x^y С/П</langsyntaxhighlight>
 
The result is error message.
 
=={{header|Nanoquery}}==
<syntaxhighlight lang ="nanoquery">println 0^0</langsyntaxhighlight>
{{out}}
<pre>1</pre>
Line 924 ⟶ 1,022:
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">/**
<lang ActionScript>/**
Zero to the zeroth power, in Neko
*/
Line 930 ⟶ 1,028:
var math_pow = $loader.loadprim("std@math_pow", 2)
 
$print(math_pow(0, 0), "\n")</langsyntaxhighlight>
 
{{out}}
Line 938 ⟶ 1,036:
 
=={{header|NetRexx}}==
<langsyntaxhighlight lang="netrexx">x=0
Say '0**0='||x**x</langsyntaxhighlight>
{{out}}
<pre>0**0=1</pre>
 
=={{header|NewLISP}}==
<syntaxhighlight lang ="newlisp">(pow 0 0)</langsyntaxhighlight>
{{out}}
<pre>1</pre>
Line 952 ⟶ 1,050:
Create an exponentiation table for all type combinations (of integer <code>0</code>, float <code>0.0</code> and boolean <code>o</code>):
 
<langsyntaxhighlight lang="nial"> 0 0.0 o outer power 0 0.0 o
+--+--+--+
| 1|1.| 1|
Line 959 ⟶ 1,057:
+--+--+--+
| 1|1.| 1|
+--+--+--+</langsyntaxhighlight>
 
=={{header|Nim}}==
<langsyntaxhighlight lang="nim">import math
 
echo pow(0.0, 0.0) # Floating point exponentiation.
echo 0 ^ 0 # Integer exponentiation.</langsyntaxhighlight>
{{out}}
<pre>1.0
Line 985 ⟶ 1,083:
=={{header|Oforth}}==
 
<syntaxhighlight lang Oforth="oforth">0 0 pow println</langsyntaxhighlight>
 
{{out}}
Line 993 ⟶ 1,091:
 
=={{header|Ol}}==
<langsyntaxhighlight lang="scheme">
(print "0^0: " (expt 0 0))
(print "0.0^0: " (expt (inexact 0) 0))
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,004 ⟶ 1,102:
 
=={{header|ooRexx}}==
<langsyntaxhighlight lang="oorexx">/**********************************************************************
* 21.04.2014 Walter Pachl
**********************************************************************/
Say 'rxCalcpower(0,0) ->' rxCalcpower(0,0)
Say '0**0 ->' 0**0
::requires rxmath library</langsyntaxhighlight>
{{out}}
<pre>
Line 1,018 ⟶ 1,116:
 
=={{header|Openscad}}==
<syntaxhighlight lang ="openscad">echo (0^0);</langsyntaxhighlight>
 
 
=={{header|PARI/GP}}==
0 raised to the power of exact 0 is 01, but 0 cannot be raised to the power of an inexact 0:
<langsyntaxhighlight lang="parigp">0^0
0.^0
0^0.</langsyntaxhighlight>
{{out}}
<pre>%1 = 1
Line 1,036 ⟶ 1,134:
=={{header|Pascal}}==
{{works with|Free Pascal}} {{Libheader|math}}
<langsyntaxhighlight Pascallang="pascal">program ZToZ;
uses
math;
Line 1,042 ⟶ 1,140:
write('0.0 ^ 0 :',IntPower(0.0,0):4:2);
writeln(' 0.0 ^ 0.0 :',Power(0.0,0.0):4:2);
end.</langsyntaxhighlight>
;output:
<pre>0.0 ^ 0 :1.00 0.0 ^ 0.0 :1.00</pre>
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">print 0 ** 0, "\n";
 
use Math::Complex;
 
print cplx(0,0) ** cplx(0,0), "\n";</langsyntaxhighlight>
{{out}}
<pre>
Line 1,060 ⟶ 1,158:
=={{header|Phix}}==
{{libheader|Phix/basics}}
<!--<langsyntaxhighlight Phixlang="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>
Line 1,069 ⟶ 1,167:
<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>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,077 ⟶ 1,175:
 
=={{header|Phixmonti}}==
<langsyntaxhighlight Phixmontilang="phixmonti">def mypower
dup not if
. sign dup 0 == if . 1 endif
Line 1,085 ⟶ 1,183:
enddef
 
0 0 mypower print</langsyntaxhighlight>
{{out}}
<pre>1</pre>
 
=={{header|PHP}}==
<langsyntaxhighlight PHPlang="php"><?php
echo pow(0,0);
echo 0 ** 0; // PHP 5.6+ only
?></langsyntaxhighlight>
{{out}}
<pre>
Line 1,101 ⟶ 1,199:
 
=={{header|PicoLisp}}==
<syntaxhighlight lang="picolisp">
<lang PicoLisp>
(** 0 0)
</syntaxhighlight>
</lang>
{{out}}
1
 
=={{header|Pike}}==
<langsyntaxhighlight Pikelang="pike">write( pow(0, 0) +"\n" );</langsyntaxhighlight>
{{Out}}
<pre>
Line 1,115 ⟶ 1,213:
 
=={{header|PL/I}}==
<langsyntaxhighlight lang="pli"> zhz: Proc Options(Main);
Dcl a dec float(10) Init(1);
Dcl b dec float(10) Init(0);
Line 1,121 ⟶ 1,219:
Put skip list('0**1=',b**a);
Put skip list('0**0=',b**b);
End;</langsyntaxhighlight>
{{out}}
<pre>
Line 1,132 ⟶ 1,230:
 
=={{header|Plain English}}==
<langsyntaxhighlight lang="plainenglish">To run:
Start up.
Put 0 into a number.
Line 1,139 ⟶ 1,237:
Write the string to the console.
Wait for the escape key.
Shut down.</langsyntaxhighlight>
{{out}}
<pre>
Line 1,147 ⟶ 1,245:
=={{header|PowerShell}}==
 
<langsyntaxhighlight lang="powershell">Write-Host "0 ^ 0 = " ([math]::pow(0,0))</langsyntaxhighlight>
 
Output :
Line 1,156 ⟶ 1,254:
 
=={{header|PureBasic}}==
<syntaxhighlight lang="purebasic">
<lang PureBasic>
If OpenConsole()
PrintN("Zero to the zero power is " + Pow(0,0))
Line 1,164 ⟶ 1,262:
CloseConsole()
EndIf
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,172 ⟶ 1,270:
 
=={{header|Pyret}}==
<syntaxhighlight lang Pyret="pyret">num-expt(0, 0)</langsyntaxhighlight>
{{out}}
1
Line 1,178 ⟶ 1,276:
=={{header|Python}}==
===Python3===
<langsyntaxhighlight lang="python">from decimal import Decimal
from fractions import Fraction
from itertools import product
Line 1,188 ⟶ 1,286:
except:
ans = '<Exception raised>'
print(f'{i!r:>15} ** {j!r:<15} = {ans!r}')</langsyntaxhighlight>
{{out}}
<pre> 0 ** 0 = 1
Line 1,256 ⟶ 1,354:
 
===Python2===
<langsyntaxhighlight lang="python">from decimal import Decimal
from fractions import Fraction
for n in (Decimal(0), Fraction(0, 1), complex(0), float(0), int(0)):
Line 1,267 ⟶ 1,365:
except:
n2 = '<Raised exception>'
print('%8s: ** -> %r; pow -> %r' % (n.__class__.__name__, n1, n2))</langsyntaxhighlight>
{{out}}
<pre>
Line 1,278 ⟶ 1,376:
 
=={{header|QB64}}==
<syntaxhighlight lang ="qb64">Print 0 ^ 0</langsyntaxhighlight>
{{out}}
<pre>1</pre>
Alternatively:
<langsyntaxhighlight QB64lang="qb64">i% = 0 'Integer
l& = 0 'Long integer
s! = 0.0 'Single precision floating point
Line 1,296 ⟶ 1,394:
Print b` ^ b`
Print bb%% ^ bb%%
Print isf&& ^ isf&&</langsyntaxhighlight>
{{out}}
NB: Values with 0 decimals are trimmed by Print's casting from number value to String.
Line 1,310 ⟶ 1,408:
As a dialogue in the Quackery shell.
 
<langsyntaxhighlight Quackerylang="quackery">/O> 0 0 **
...
 
Stack: 1
</syntaxhighlight>
</lang>
 
=={{header|R}}==
<syntaxhighlight lang ="rsplus">print(0^0)</langsyntaxhighlight>
{{out}}
<pre>1</pre>
Line 1,323 ⟶ 1,421:
=={{header|Racket}}==
 
<langsyntaxhighlight lang="racket">#lang racket
;; as many zeros as I can think of...
(define zeros (list
Line 1,336 ⟶ 1,434:
(printf "(~a)^(~a) = ~s~%" z p
(with-handlers [(exn:fail:contract:divide-by-zero? exn-message)]
(expt z p))))</langsyntaxhighlight>
 
{{out}}
Line 1,380 ⟶ 1,478:
 
{{works with|Rakudo|2018.03}}
<syntaxhighlight lang="raku" perl6line>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($_,$_);
}</langsyntaxhighlight>
 
{{out}}
Line 1,400 ⟶ 1,498:
=={{header|Red}}==
Shown using the operator, the function, and the <code>math</code> mini-DSL that uses the order of operations from mathematics:
<langsyntaxhighlight lang="rebol">Red[]
print 0 ** 0
print power 0 0
print math [0 ** 0]</langsyntaxhighlight>
{{out}}
<pre>
Line 1,412 ⟶ 1,510:
 
=={{header|Relation}}==
<syntaxhighlight lang="relation">
<lang Relation>
echo pow(0,0)
// 1
</syntaxhighlight>
</lang>
 
=={{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
Line 1,450 ⟶ 1,548:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
x = 0
y = 0
z = pow(x,y)
see "z=" + z + nl # z=1
</syntaxhighlight>
</lang>
 
=={{header|RPL}}==
0 0 ^
====Output for HP-48G and older models====
1: 1
====Output for HP-49 and newer models====
1: ?
 
=={{header|Ruby}}==
<langsyntaxhighlight 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</langsyntaxhighlight>
{{out}}
<pre>
Line 1,473 ⟶ 1,578:
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">fn main() {
println!("{}",0u32.pow(0));
}</langsyntaxhighlight>
 
{{out}}
Line 1,481 ⟶ 1,586:
 
=={{header|S-lang}}==
<syntaxhighlight lang S="s-lang">print(0^0);</langsyntaxhighlight>
{{out}}
<pre>1.0</pre>
 
=={{header|Scala}}==
{{libheader|Scala}}<langsyntaxhighlight Scalalang="scala"> assert(math.pow(0, 0) == 1, "Scala blunder, should go back to school !")</langsyntaxhighlight>
 
=={{header|Scheme}}==
<langsyntaxhighlight lang="scheme">(display (expt 0 0)) (newline)
(display (expt 0.0 0.0)) (newline)
(display (expt 0+0i 0+0i)) (newline)</langsyntaxhighlight>
{{out}}
<pre>1
Line 1,498 ⟶ 1,603:
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "float.s7i";
include "complex.s7i";
Line 1,509 ⟶ 1,614:
writeln("0.0+0i ** 0 = " <& complex(0.0) ** 0);
end func;
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,520 ⟶ 1,625:
 
=={{header|SenseTalk}}==
<langsyntaxhighlight lang="sensetalk">set a to 0
set b to 0
 
put a to the power of b
// Prints: 1</langsyntaxhighlight>
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">[0, Complex(0, 0)].each {|n|
say n**n
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,538 ⟶ 1,643:
Taking the 0'th root of a number and raising it back to the zero power, we also get a 1:
 
<langsyntaxhighlight lang="ruby">say 0.root(0).pow(0) # => 1
say ((0**(1/0))**0) # => 1</langsyntaxhighlight>
 
=={{header|Sinclair ZX81 BASIC}}==
<syntaxhighlight lang ="basic">PRINT 0**0</langsyntaxhighlight>
{{out}}
<pre>1</pre>
Line 1,548 ⟶ 1,653:
=={{header|Smalltalk}}==
 
<langsyntaxhighlight lang="smalltalk">
0 raisedTo: 0
0.0 raisedTo: 0.0
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,559 ⟶ 1,664:
 
=={{header|smart BASIC}}==
<syntaxhighlight lang ="qbasic">PRINT 0^0</langsyntaxhighlight>
 
{{out}}
Line 1,568 ⟶ 1,673:
 
=={{header|SNOBOL4}}==
<langsyntaxhighlight lang="snobol4"> OUTPUT = (0 ** 0)
END</langsyntaxhighlight>
 
 
=={{header|SQL}}==
<syntaxhighlight lang="sql">
<lang SQL>
SQL> select power(0,0) from dual;
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,591 ⟶ 1,696:
 
=={{header|Stata}}==
<langsyntaxhighlight lang="stata">. display 0^0
1</langsyntaxhighlight>
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">import Darwin
print(pow(0.0,0.0))</langsyntaxhighlight>
{{out}}
<pre>1.0</pre>
 
=={{header|Symsyn}}==
<syntaxhighlight lang="symsyn">
<lang Symsyn>
(0^0) []
</syntaxhighlight>
</lang>
{{out}}
<pre> 1 </pre>
Line 1,609 ⟶ 1,714:
=={{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</langsyntaxhighlight>
{{out}}
<pre>ERROR:DOMAIN</pre>
 
=={{header|uBasic/4tH}}==
<syntaxhighlight lang="text">Print 0^0</langsyntaxhighlight>
{{out}}
<pre>1
Line 1,628 ⟶ 1,739:
=={{header|Ursa}}==
Cygnus/X Ursa is written in Java, and as a result returns 1.0 when raising 0 to the 0.
<langsyntaxhighlight lang="ursa">> out (pow 0 0) endl console
1.0</langsyntaxhighlight>
 
=={{header|VBA}}==
<langsyntaxhighlight lang="vb">Public Sub zero()
x = 0
y = 0
z = 0 ^ 0
Debug.Print "z ="; z
End Sub</langsyntaxhighlight>{{out}}
<pre>z = 1</pre>
 
=={{header|VBScript}}==
<syntaxhighlight lang ="vb">WScript.Echo 0 ^ 0</langsyntaxhighlight>
{{Out}}
<pre>1</pre>
Line 1,647 ⟶ 1,758:
 
=={{header|Verilog}}==
<langsyntaxhighlight Veriloglang="verilog">module main;
initial begin
$display("0 ^ 0 = ", 0**0);
$finish ;
end
endmodule</langsyntaxhighlight>
{{out}}
<pre>0 ^ 0 = 1</pre>
Line 1,658 ⟶ 1,769:
 
=={{header|Visual Basic .NET}}==
<langsyntaxhighlight lang="vbnet">Module Program
Sub Main()
Console.Write(0^0)
End Sub
End Module</langsyntaxhighlight>
 
{{out}}
<pre>1</pre>
 
=={{header|V (Vlang)}}==
<langsyntaxhighlight lang="go">// Zero to the zero power, in V
// Tectonics: v run zero-to-the-zero-power.v
module main
Line 1,677 ⟶ 1,788:
pub fn main() {
println(math.pow(0, 0))
}</langsyntaxhighlight>
{{out}}<pre>prompt$ v run rosetta/zero-to-the-zero-power.v
1.</pre>
 
=={{header|Wren}}==
<syntaxhighlight lang ecmascript="wren">System.print(0.pow(0))</langsyntaxhighlight>
 
{{out}}
Line 1,690 ⟶ 1,801:
 
=={{header|XLISP}}==
<langsyntaxhighlight lang="scheme">XLISP 3.3, September 6, 2002 Copyright (c) 1984-2002, by David Betz
[1] (expt 0 0)
 
1
[2] </langsyntaxhighlight>
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">RlOut(0, Pow(0., 0.))</langsyntaxhighlight>
{{out}}
<pre> 1.00000</pre>
 
=={{header|Zig}}==
<langsyntaxhighlight 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)});
}</langsyntaxhighlight>
{{out}}
<pre>0^0 = 1.00000000</pre>
 
=={{header|zkl}}==
<langsyntaxhighlight lang="zkl">(0.0).pow(0) //--> 1.0
var BN=Import("zklBigNum"); // big ints
BN(0).pow(0) //--> 1</langsyntaxhighlight>
56

edits