Yosemite decimal number conversion error
Yosemite decimal number conversion error
- Subject: Yosemite decimal number conversion error
- From: Takaaki Naganoya <email@hidden>
- Date: Wed, 29 Oct 2014 11:40:39 +0900
I found an error with decimal number conversion from AppleScript's ‘real' into Cocoa's ‘float'.
Is it well-known?
I found this when I check the sorting result…. List-NSArray-list conversion broke original list data.
<AppleScript>
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
set a to 0.100001
set b to numberFloatWith_(a)
--> 0.100000999868
set c to numberDoubleWith_(a)
--> 0.100000999868
set d to numberLongWith_(a)
--> 0.0
set e to 0.1
set f to numberFloatWith_(e)
--> 0.10000000149
--Float
on numberFloatWith:aNum
set theNum to current application's NSNumber's numberWithFloat:aNum
return (theNum as real)
end numberFloatWith:
--Double
on numberDoubleWith:aNum
set theNum to current application's NSNumber's numberWithDouble:aNum
return (theNum as real)
end numberDoubleWith:
--Long
on numberLongWith:aNum
set theNum to current application's NSNumber's numberWithLong:aNum
return (theNum as real)
end numberLongWith:
</AppleScript>
--
Takaaki Naganoya
email@hidden
http://piyocast.com/as/
_______________________________________________
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