1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--***********************************************************
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements.  See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership.  The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License.  You may obtain a copy of the License at
12 *
13 *   http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied.  See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22 ***********************************************************-->
23
24<helpdocument version="1.0">
25<meta>
26<topic id="textsbasicshared03080701xml" indexer="include" status="PUBLISH">
27<title id="tit" xml-lang="en-US">Sgn Function [Runtime]</title>
28<filename>/text/sbasic/shared/03080701.xhp</filename>
29</topic>
30</meta>
31<body>
32<section id="sgn">
33<bookmark xml-lang="en-US" branch="index" id="bm_id3148474">
34<bookmark_value>Sgn function</bookmark_value>
35</bookmark>
36<paragraph role="heading" id="hd_id3148474" xml-lang="en-US" level="1" l10n="U" oldref="1"><link href="text/sbasic/shared/03080701.xhp" name="Sgn Function [Runtime]">Sgn Function [Runtime]</link></paragraph>
37<paragraph role="paragraph" id="par_id3148686" xml-lang="en-US" l10n="U" oldref="2">Returns an integer number between -1 and 1 that indicates if the number that is passed to the function is positive, negative, or zero.</paragraph>
38</section>
39<paragraph role="heading" id="hd_id3156023" xml-lang="en-US" level="2" l10n="U" oldref="3">Syntax:</paragraph>
40<paragraph role="paragraph" id="par_id3153897" xml-lang="en-US" l10n="U" oldref="4">Sgn (Number)</paragraph>
41<paragraph role="heading" id="hd_id3145069" xml-lang="en-US" level="2" l10n="U" oldref="5">Return value:</paragraph>
42<paragraph role="paragraph" id="par_id3150359" xml-lang="en-US" l10n="U" oldref="6">Integer</paragraph>
43<paragraph role="heading" id="hd_id3150543" xml-lang="en-US" level="2" l10n="U" oldref="7">Parameters:</paragraph>
44<paragraph role="paragraph" id="par_id3154365" xml-lang="en-US" l10n="U" oldref="8">
45<emph>Number:</emph> Numeric expression that determines the value that is returned by the function.</paragraph>
46<table id="tbl_id3156281">
47<tablerow>
48<tablecell colspan="" rowspan="">
49<paragraph role="paragraph" id="par_id3150767" xml-lang="en-US" l10n="U" oldref="9">NumExpression</paragraph>
50</tablecell>
51<tablecell colspan="" rowspan="">
52<paragraph role="paragraph" id="par_id3150441" xml-lang="en-US" l10n="U" oldref="10">Return value</paragraph>
53</tablecell>
54</tablerow>
55<tablerow>
56<tablecell colspan="" rowspan="">
57<paragraph role="paragraph" id="par_id3161833" xml-lang="en-US" l10n="U" oldref="11">negative</paragraph>
58</tablecell>
59<tablecell colspan="" rowspan="">
60<paragraph role="paragraph" id="par_id3155306" xml-lang="en-US" l10n="U" oldref="12">Sgn returns -1.</paragraph>
61</tablecell>
62</tablerow>
63<tablerow>
64<tablecell colspan="" rowspan="">
65<paragraph role="paragraph" id="par_id3145271" xml-lang="en-US" l10n="U" oldref="13">0</paragraph>
66</tablecell>
67<tablecell colspan="" rowspan="">
68<paragraph role="paragraph" id="par_id3146119" xml-lang="en-US" l10n="U" oldref="14">Sgn returns 0.</paragraph>
69</tablecell>
70</tablerow>
71<tablerow>
72<tablecell colspan="" rowspan="">
73<paragraph role="paragraph" id="par_id3153139" xml-lang="en-US" l10n="U" oldref="15">positive</paragraph>
74</tablecell>
75<tablecell colspan="" rowspan="">
76<paragraph role="paragraph" id="par_id3154319" xml-lang="en-US" l10n="U" oldref="16">Sgn returns 1.</paragraph>
77</tablecell>
78</tablerow>
79</table>
80<embed href="text/sbasic/shared/00000003.xhp#errorcode"/>
81<embed href="text/sbasic/shared/00000003.xhp#err5"/>
82<paragraph role="heading" id="hd_id3152576" xml-lang="en-US" level="2" l10n="U" oldref="17">Example:</paragraph>
83<paragraph role="paragraph" id="par_id3154791" xml-lang="en-US" l10n="U" oldref="18">Sub ExampleSgn</paragraph>
84<paragraph role="paragraph" id="par_id3155416" xml-lang="en-US" l10n="U" oldref="19">Print sgn(-10) REM returns -1</paragraph>
85<paragraph role="paragraph" id="par_id3154096" xml-lang="en-US" l10n="U" oldref="20">Print sgn(0) REM returns 0</paragraph>
86<paragraph role="paragraph" id="par_id3148457" xml-lang="en-US" l10n="U" oldref="21">Print sgn(10) REM returns 1</paragraph>
87<paragraph role="paragraph" id="par_id3144765" xml-lang="en-US" l10n="U" oldref="22">end sub</paragraph>
88</body>
89</helpdocument>
90