Zero to the zero power

From Rosetta Code
Revision as of 22:12, 18 March 2014 by Sonia (talk | contribs) (Go solution)
Zero to the zero power is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Some programming languages are not exactly consistent (with other programming languages) when raising zero to the zeroth power   00.

task requirements

Show the results of raising zero to the zeroth power.

If your computer language objects to   0**0   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
  • Also, in the above Wiki entry, scroll down to:   Zero to the power of zero.
  • Also, in the above Wiki entry, scroll further down to:   History of differing points of view
  • Also, in the above MathWorld (TM) entry, see formula (9):   x0 == 1.



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. <lang go>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))

}</lang>

Output:
float64:     1
big integer: 1
complex:     (0+0i)

REXX


using PC/REXX
using Personal REXX
using REGINA <lang rexx>/*REXX program shows the results of raising zero to the zeroth power.*/ say '0 ** 0 (zero to the zeroth power) ───► ' 0**0</lang> output

0 ** 0  (zero to the zeroth power) ───►  1


using R4 <lang rexx>∙∙∙ same program ∙∙∙</lang> 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 <lang rexx>∙∙∙ same program ∙∙∙</lang> 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