Re: Simple multiplication going bizarre
Re: Simple multiplication going bizarre
- Subject: Re: Simple multiplication going bizarre
- From: "Stockly, Ed" <email@hidden>
- Date: Thu, 29 Apr 2010 12:00:58 -0500
- Acceptlanguage: en-US
- Thread-topic: Simple multiplication going bizarre
Title: Re: Simple multiplication going bizarre
‘As number’ doesn’t do it. It’s the coercion to a text string that happens in Display Dialog that gives you the conversion.
set myVal to 4999.0 * 12.5
display dialog myVal
Funny, though, as text still gives you an exponent
set myVal to 4999.0 * 12.5 as text
display dialog myVal
‘As integer’ is no good, if you need fractional values (like when dealing with currency)
This is what I would use instead:
set myVal to 4999.0 * 12.5
set divVal to ((myVal div 1) as text)
set modVal to (myVal mod 1) * 10 as integer
set myVal to divVal & "." & modVal
display dialog myVal
Same thing as a one-liner:
set myVal to 4999.0 * 12.5
set myVal to ((myVal div 1) as text) & "." & ((myVal mod 1) * 10 as integer)
All these solutions give you a text value. If you’re doing further calculations, I’d keep using the exponent version until you have to display the text value.
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden