51 routines :

*AppleScriptsVanilla*
ascii_to_HTML
Average
Calculator
Calendar
Count_item
cut_text
days_week
EAN13
Encrypt-Decrypt
FactPremier
French_Vanilla_Dotted_Date
French_Vanilla_Dotted_Date2
Hexa_to_Bin
Last_month
list_erase
list_insert
list_replace
ListeDiviseurs
ListePremiers
Minuscule
NombreLong
NombreLong2
NomExtension
num_item
num_month
num_month2
num_week
number_format
number_format2
Paques
PGCD
PGCD2
reverse_string
Roman_to_Arab
round_decimal
search_email
search_replace
search_URL
SepNbre
SepNbre2
snip_text
stat
TauxPermut
TauxTransform
the_left
the_right
TriBulle
TriLineaire
week_and_year
XOR
ZeroDouble

NombreLong

Syntaxe

NombreLong1(NroOrig)
Convertit un nombre long en notation exponentielle en chaîne de caractères. Le paramètre est au format nombre, le résultat est au format texte. Traite les nombres longs au délà de + 536870911 ou en déçà de - 536870911
Par Fredo d;o)

Exemple

NombreLong1(536870911 * (pi ^ pi))
(=1.95754728453491E+10)
---> "19575472845,35"

Script

on NombreLong1(NroOrig)
set {NroTxt, NroOk, Coma} to ¬
{NroOrig as text, NroOrig as text, item 2 of (0.0 as text)}
if "E" is in NroTxt then
set {PlcPoint, PlcE} to ¬
{offset of Coma in NroTxt, offset of "E" in NroTxt}
set {PlcSgnNeg, PlcSgnPos} to ¬
{offset of "-" in NroTxt, offset of "+" in NroTxt}
set PlcSgn to PlcSgnNeg + PlcSgnPos
set DecOrig to (text (PlcPoint + 1) thru (PlcE - 1) of NroTxt)
set EntOrig to (text 1 thru (PlcPoint - 1) of NroTxt)
set NbrDecOrig to length of DecOrig
set NbrDecNew to ¬
((text (PlcE + 1) thru -1 of NroTxt) as text) as number

if (NbrDecOrig > NbrDecNew) then
set EntNew to (EntOrig & (text (PlcPoint + 1) ¬
thru (PlcPoint + NbrDecNew) of NroTxt))
set DecNew to (Coma & (text (PlcPoint + NbrDecNew + 1) ¬
thru (PlcE - 1) of NroTxt))
else
set {Zrs, LstZrs} to {"", "0000000000000000"}
set NbrZrs to (NbrDecNew - NbrDecOrig) div 1
if (NbrZrs > 0) then set Zrs to (text 1 thru NbrZrs of LstZrs)
set {EntNew, DecNew} to {(EntOrig & DecOrig & Zrs) as text, ""}
end if
set NroOk to (EntNew & DecNew) as text
end if
return NroOk
end NombreLong1

Remarque

Routine moins précise que NombreLong2 mais plus "silencieuse" .

Site scripté avec HyperCard ©1987-1998 Apple Computer, Inc.
Mise à jour le 19/01/10 à 08:45:57