第二十三節資料轉換函式

2022-12-19 06:45:05 字數 3906 閱讀 6127

conversion functionschartostr()doubletostr()normalizedouble()strtodouble()strtointeger()strtotime()timetostr()

stringchartostr(intchar_code)

returns string with one symbol that h**e specified code

parameters

char_code-ascii char code.

samplestring str;

str = "worl" + chartostr(44); // 44 is code for 'd'// resulting string will be world

stringdoubletostr(doublevalue,intdigits)

returns text string with the specified numerical value transformed into the specified precision format.

parameters

value-numerical value.

digits-precision format, number of digits after decimal point (0-8).

sample

string value = doubletostr(1.28473418, 5);// value is 1.28473

doublenormalizedouble(doublevalue,intdigits)

rounds floating point number to specified decimal places.

parameters

value-floating point value.

digits-precision format, number of digits after decimal point (0-8).

sample

double var1=0.123456789;

print(normalizedouble(var1,5));// output: 0.12346

doublestrtodouble(strin**alue)

converts string representation of number to type double.

parameters

value-string containing value in fixed number format.

sample

double var = strtodouble("103.2812");

intstrtointeger(strin**alue)

converts string representation of number to type integer.

parameters

value-string containing integer number.

sampleint var1;

var1 = strtointeger("1024");

datetimestrtotime(strin**alue)

converts string in the format " hh:mi" to type datetime.

parameters

value-string value of date/time format such as " hh:mi".

sample

datetime var1;

var1 = strtotime("2003.8.12 17:35");

var1 = strtotime("17:35returns with current date

var1=strtotime("2003.8.12"); //returnswithmidnighttime"00:00"

stringtimetostr(datetimevalue,intmode=time_date|time_minutes)

returns time as string in the format " hh:mi".

parameters

value-positive number of seconds from 00:00 january 1, data output mode can be one or combination of:

time_date get result in form "",time_minutes get result in form "hh:mi",time_seconds get result in form "hh:mi:

ss".

sample

strign var1;

var1 = timetostr(curtime(),time_date|time_seconds);

型別轉換函式[conversion functions]

string chartostr( int char_code)將字元型轉換成字串型結果返回

::輸入引數

char_code -字元的acsii碼

示例:string str="worl" + chartostr(44); // 44 is code for 'd'// resulting string will be world

string doubletostr( double value, int digits)將雙精度浮點型轉換成字串型結果返回

::輸入引數value -浮點型數字

digits -小數點後多少位,0-8

示例:string value=doubletostr(1.28473418, 5);// value is 1.28473

double normalizedouble( double value, int digits)

將雙精度浮點型格式化後結果返回

::輸入引數value -浮點型數字

digits -小數點後多少位,0-8

示例:double var1=0.123456789;print(normalizedouble(var1,5));// output: 0.12346

double strtodouble( string value)將字串型轉換成雙精度浮點型結果返回

::輸入引數

value -數字的字串

示例:double var=strtodouble("103.2812");

int strtointeger( string value)將字串型轉換成整型結果返回

::輸入引數

value -數字的字串

示例:int var1=strtointeger("1024");

datetime strtotime( string value)

將字串型轉換成時間型結果返回,輸入格式為 hh:mi

::輸入引數

value -時間的字串

示例:datetime var1;

var1=strtotime("2003.8.12 17:35");

var1=strtotime("17:35"); // returns with current date

var1=strtotime("2003.8.12"); // returns with midnight time "00:00"

string timetostr( datetime value, int mode=time_date|time_minutes)將時間型轉換成字串型返回

::輸入引數

value -時間的數字,從1970.1.1 0:0:0到現在的秒數mode-返

回字串

的格式time_date(

示例:strign var1=timetostr(curtime(),time_date|time_seconds);

第二十三章技術合同

1技術合同概述 技術合同的訂立 1.訂立 技術開發合同 技術轉讓合同應當採用書面形式。技術合同不得以妨礙技術進步 損害他人技術成果或非法壟斷技術為目的 2.技術合同無效的特殊規定 非法壟斷技術 妨礙技術進步或者侵害他人技術成果的技術 合同無效。技術合同的主要內容 特有條款 1保密條款。2.成果歸屬條...

第二十三章委託合同

我國 合同法 第402和第403條規定了隱名 和未披露委託人的 一 關於隱名 的問題 1 構成要件 1 受託人在以自己的名義訂閱合同。與一般的委託不同。2 受託人在以委託人授權的範圍內行為。3 第三人知道受託人的 關係存在。2 法律後果 可以在委託人和第三人之間直接產生權利義務關係 二 未披露委託人...

第二十三章旋轉檢測題

姓名做題感受 一 選擇題 每小題3分,共30分 1.下面圖形中,既是軸對稱圖形又是中心對稱圖形的是 2.下列圖形中,是中心對稱圖形的有 a 4個b 3個c 2個d 1個 3.在平面直角座標系中,已知點,若將繞原點逆時針旋轉得到,則點在平面直角座標系中的位置是在 a.第一象限 b.第二象限 c.第三象...