| Deutsch English Français Italiano |
|
<sofv6h$psa$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: "M.V." <mv@gmail.com.invalid>
Newsgroups: fr.comp.sys.mac.programmation
Subject: Re: =?UTF-8?B?WSBhIGNvbW1lIHVuIGTDqWZhdXQ=?=
Supersedes: <sofuv0$lof$1@dont-email.me>
Date: Sat, 4 Dec 2021 14:49:53 -0000 (UTC)
Organization: M.V. & Co
Lines: 66
Archive: no
Message-ID: <sofv6h$psa$1@dont-email.me>
References: <1pjmz6k.1v0nod6mfq0rkN%josephb@nowhere.invalid>
<j0vto8FsgsuU1@mid.individual.net>
<1pjnmh9.11fmmgjvnnxyuN%josephb@nowhere.invalid>
<j1168nF58rjU1@mid.individual.net>
<1pjo2wu.1hc52gb1l7s1a3N%josephb@nowhere.invalid>
Reply-To: michel.vauquois@gmail.com
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Dec 2021 14:49:53 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="86f5a28fe29f37447a6fc4caac72ce32";
logging-data="26506"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/OwyhjmBvUwGXa1G31UxReXIQqvBjbZAo="
User-Agent: MacCafe/2.07b1 (macOS 10.14.6 (18G9323) - MacBookAir7,2)
Cancel-Key: sha1:BU6FfG1nVdb2rztVdG522IBNiX0= sha256:MTg2TJ7hx6LNUnBZHB6zk7RC+0tJqFC8xaITRLxJqmc=
Cancel-Lock: sha1:6Ouz/LHG1uqnsET58VhDfuLwyUs= sha256:s98EKCkgLrYTNosd9o/jvW9Nd1faNAcde/7yMB4003Q=
sha1:RXDU+5XZtoD7EQQSAdhihWqJPEU=
X-No-Archive: yes
In-Reply-To: <1pjo2wu.1hc52gb1l7s1a3N%josephb@nowhere.invalid>
X-Face: 0f|`H5*Our0P$s'uj0)fS=&`R#U+JYpl<W.~uGMH[S}%Yo{$(f$0`!02mu$5b`f7Hp6:EiW
c`zw`Y^GQAA=_IIV`NIXW4&YpH]>e<6GW!O'TO4sB4,Q9"tHNQo]\7p\,,nCZ_saH4~Ie
'gYktutVOXK})aU*/@meZ_y=ixi8qwcJ,ssAk~G4Rr?qr60d_euHkHHJ_;EHES_(IExNo
h6
URL-perso: http://michelvauquois.fr
Mail-Copies-To: never
Bytes: 4098
[Supersedes: <sofuv0$lof$1@dont-email.me>]
Le 4 décembre 2021 à 15 h 25, Joseph-B a tenu les propos suivants :
> Pour reprendre l'exemple de MV,
> (2.001 -2) avec une calculette à moins d'un euro retournera 0,001
> Ouais, mais c'est moche et trivial tandis que
> (2.001 -2) dans AppleScript retournera 9.9999999999989E-4
En même temps on n'est pas loin de la vérité mathématique car, si tu te
rappelles tes cours de math du siècle dernier :
1 = 0,99999999999999999999999999999999… (ad libitum) ! ;-)
Ceci dit, je partage ton courroux (coucou) surtout quand je vois le
script que j'ai dû pondre pour obtenir un résultat correct (jusqu'à
preuve du contraire) pour éviter des résultats à la mords-moi le nœud.
J'en suis là :
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
set diviseur to 25.4
set serie to {0.254, 2.54, 25.4001, 254, 2540}
set restes to {}
set text item delimiters to " - "
set commentaire to "Restes de la division par " & (diviseur as text) & " de" & linefeed & (serie as string)
set exp0 to exp_value(diviseur)
log "exp0 : " & exp0
repeat with value in serie
set exp1 to exp_value(value)
log "exp1 : " & exp1
-- pour transformer 25.4 et 25.4001 par exemple en 254000 et 254001
if exp1 ≥ exp0 then
set exp to exp1
else
set exp to exp0
end if
set new_value to (value * (10 ^ exp)) as integer
set new_diviseur to (diviseur * (10 ^ exp)) as integer
set reste to (new_value mod new_diviseur) / (10 ^ exp)
if reste = (reste as integer) then set reste to reste as integer
copy reste to the end of restes
end repeat
set text item delimiters to " - "
display alert (restes's every item as text) message commentaire
-- combien de chiffres dans la partie décimale
on exp_value(nombre)
set nombre_str to nombre as string
log "nombre_str : " & nombre_str
set text item delimiters to ","
try
set exp to count characters of second text item of nombre_str
on error
set exp to 0
end try
return exp
end exp_value
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
--
Michel VAUQUOIS - <http://michelvauquois.fr>