Difference between revisions of "Documentation/How Tos/Calc: N function"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Initial content)
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
+
{{Documentation/MasterTOC
 +
|bookid=1234'''
 +
|booktitle=<div style="padding: 8px; font-size: 140%; font-weight: bold; background-color: #9BC0F5;">CALC FUNCTIONS</div>
 +
|ShowParttitle=block|parttitle=[[Documentation/How_Tos/Calc:_Information_functions|<div style="font-size: 140%;">Information Functions]]
 +
|ShowNextPage=block|NextPage=Documentation/How_Tos/Calc:_NA_function
 +
|ShowPrevPage=block|PrevPage=Documentation/How_Tos/Calc:_ISTEXT_function
 +
|ShowPrevPart=block|PrevPart=Documentation/How_Tos/Calc:_Financial_functions
 +
|ShowNextPart=block|NextPart=Documentation/How_Tos/Calc:_Logical_functions
 +
|toccontent= <div style="padding: 4px; font-size: 130%; font-weight: hidden; background-color:#DCE9FC;">FUNCTIONS</div>
  
 +
* [[Documentation/How_Tos/Calc:_CELL_function|<div style="font-size: 120%;">Cell]]
 +
* [[Documentation/How_Tos/Calc:_CURRENT_function|<div style="font-size: 120%;">Current]]
 +
* [[Documentation/How_Tos/Calc:_FORMULA_function|<div style="font-size: 120%;">Formula]]
 +
* [[Documentation/How_Tos/Calc:_ISBLANK_function|<div style="font-size: 120%;">Isblank]]
 +
* [[Documentation/How_Tos/Calc:_ISERR_function|<div style="font-size: 120%;">Iserr]]
 +
* [[Documentation/How_Tos/Calc:_ISERROR_function|<div style="font-size: 120%;">Iserror]]
 +
* [[Documentation/How_Tos/Calc:_ISEVEN_function|<div style="font-size: 120%;">Iseven]]
 +
* [[Documentation/How_Tos/Calc:_ISEVEN_ADD_function|<div style="font-size: 120%;">Iseven Add]]
 +
* [[Documentation/How_Tos/Calc:_ISLOGICAL_function|<div style="font-size: 120%;">Islogical]]
 +
* [[Documentation/How_Tos/Calc:_ISNA_function|<div style="font-size: 120%;">Isna]]
 +
* [[Documentation/How_Tos/Calc:_ISNONTEXT_function|<div style="font-size: 120%;">Isnontext]]
 +
* [[Documentation/How_Tos/Calc:_ISNUMBER_function|<div style="font-size: 120%;">Isnumber]]
 +
* [[Documentation/How_Tos/Calc:_ISODD_function|<div style="font-size: 120%;">Isodd]]
 +
* [[Documentation/How_Tos/Calc:_ISODD_ADD_function|<div style="font-size: 120%;">Isodd Add]]
 +
* [[Documentation/How_Tos/Calc:_ISREF_function|<div style="font-size: 120%;">Isref]]
 +
* [[Documentation/How_Tos/Calc:_ISTEXT_function|<div style="font-size: 120%;">Istext]]
 +
* [[Documentation/How_Tos/Calc:_N_function|<div style="font-size: 120%; border-style: double; border-color:#778899;">N]]
 +
* [[Documentation/How_Tos/Calc:_NA_function|<div style="font-size: 120%;">Na]]
 +
* [[Documentation/How_Tos/Calc:_TYPE_function|<div style="font-size: 120%;">Type]]
 +
}}__TOC__
 
== N ==
 
== N ==
 
Returns the numeric value.
 
Returns the numeric value.
Line 8: Line 36:
 
<tt>'''N(value)'''</tt>
 
<tt>'''N(value)'''</tt>
  
:This function returns the numeric value of <tt>'''value'''</tt> if possible and <tt>'''0'''</tt> otherwise. It returns the logical values <tt>'''TRUE'''</tt> and <tt>'''FALSE'''</tt> as <tt>'''1'''</tt> and <tt>'''0'''</tt> respectively, and converts text representing a number to that number. It returns non-numeric text and errors as <tt>'''0'''</tt>.
+
: returns the numeric value of <tt>'''value'''</tt> if possible. It returns the logical values <tt>'''TRUE'''</tt> and <tt>'''FALSE'''</tt> as <tt>'''1'''</tt> and <tt>'''0'''</tt> respectively.
 +
 
 +
: <tt>'''N()'''</tt> is not intended to convert text to a number - use the <tt>'''VALUE()'''</tt> function instead.
  
  
Line 21: Line 51:
 
: where A3 contains <tt>'''FALSE'''</tt>, returns <tt>'''0'''</tt>.
 
: where A3 contains <tt>'''FALSE'''</tt>, returns <tt>'''0'''</tt>.
  
<tt>'''N("abc")'''</tt>
+
===Issues: ===
: returns <tt>'''0'''</tt>, because <tt>'''"abc"'''</tt> is text which cannot be converted to a number.
+
<tt>'''N()'''</tt> in Calc will sometimes convert text to a number, but in Excel will always return text as <tt>'''0'''</tt>. In Calc <tt>'''N("4")'''</tt> returns <tt>'''0'''</tt> in OOo3 but <tt>'''4'''</tt> in OOo2. {{Issue|113739}} describes some further inconsistencies in the handling of text. In fact, the ODFF standard deliberately does not specify a behaviour. It may be better to use <tt>'''VALUE()'''</tt> to convert from text to number.
 
+
<tt>'''N("1.23")'''</tt>
+
:  returns <tt>'''1.23'''</tt> as a number.
+
  
 +
{{SeeAlso|EN|
 +
* [[Documentation/How_Tos/Calc: ISNUMBER function|ISNUMBER]]
 +
* [[Documentation/How_Tos/Calc: VALUE function|VALUE]]
 +
* [[Documentation/How_Tos/Calc: T function|T]]
 +
* [[Documentation/How_Tos/Calc: TEXT function|TEXT]]
 +
* [[Documentation/How_Tos/Calc: FIXED function|FIXED]]
 +
* [[Documentation/How_Tos/Calc: DECIMAL function|DECIMAL]]
  
=== See also: ===
+
* [[Documentation/How_Tos/Calc: Information functions|Information functions]]
'''[[Documentation/How_Tos/Calc: ISNUMBER function|ISNUMBER function]]'''
+
  
'''[[Documentation/How_Tos/Calc: Information functions|Information functions]]'''
+
* [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]]
 +
* [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}}
 +
[[Category: Documentation/Reference/Calc/Information functions]]

Revision as of 12:32, 16 July 2018


N

Returns the numeric value.


Syntax:

N(value)

returns the numeric value of value if possible. It returns the logical values TRUE and FALSE as 1 and 0 respectively.
N() is not intended to convert text to a number - use the VALUE() function instead.


Example:

N(123)

returns 123, because 123 is (already) a number.

N(TRUE)

returns 1.

N(A3)

where A3 contains FALSE, returns 0.

Issues:

N() in Calc will sometimes convert text to a number, but in Excel will always return text as 0. In Calc N("4") returns 0 in OOo3 but 4 in OOo2. Issue 113739 describes some further inconsistencies in the handling of text. In fact, the ODFF standard deliberately does not specify a behaviour. It may be better to use VALUE() to convert from text to number.



See Also
Retrieved from "https://wiki.openoffice.org/w/index.php?title=Documentation/How_Tos/Calc:_N_function&oldid=243224"
Views
Personal tools
Navigation
Tools