[Newbies] How to round a float?

Louis LaBrunda Lou at Keystone-Software.com
Wed Feb 4 14:36:09 UTC 2015


Hi Guys,

On Wed, 4 Feb 2015 08:22:02 -0500, Johann Hibschman <johannh at gmail.com>
wrote:

>That just looks like floating-point representation. It's as rounded as it
>can get!
>-Johann

At first I thought some more parans "(" were needed but that didn't change
anything.  No this sounds like a bug to me (ar at least something that can
be improved) as VA Smalltalk prints 162.89, so somehow they are able to
make the floats do the right thing.

Lou


>
>On Wed, Feb 4, 2015 at 6:22 AM, Chuck Hipschman <ckhipschman at gmail.com>
>wrote:
>
>> 7 / 8.0 roundTo 0.01 = 0.88  Aha! Thanks!
>>
>> But:
>>
>> 100 * (1.05 raisedTo: 10) roundTo: 0.01 162.89000000000001
>>
>> "162.88946267774418" "unrounded"
>> 100 * (1.05 raisedTo: 15) roundTo: 0.01 207.89000000000001
>>
>>  "207.8928179411367"  "unrounded"
>>  Bug, or me again :-)
>>
>> MacBook Pro (Retina, 15-inch, Early 2013)  System Version: OS X 10.10.2
>> (14C109)
>>
>> Image
>> -----
>>
>> /Users/chuck/Downloads/Squeak-4.5-All-In-One/Squeak-4.5-All-in-One.app/Contents/Resources/Squeak4.5-13680.image
>> Squeak4.5
>> latest update: #13680
>> Current Change Set: Unnamed1
>> Image format 6505 (32 bit)
>>
>> Virtual Machine
>> ---------------
>>
>> /Users/chuck/Downloads/Squeak-4.5-All-In-One/Squeak-4.5-All-in-One.app/Contents/MacOS/Squeak
>> Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.331] 4.5
>> Mac OS X built on Aug 22 2013 10:08:05 Compiler: 4.2.1 (Apple Inc. build
>> 5666) (dot 3)
>> platform sources revision VM: r2776
>> http://www.squeakvm.org/svn/squeak/branches/Cog Plugins: r2545
>> http://squeakvm.org/svn/squeak/trunk/platforms/Cross/plugins
>> CoInterpreter VMMaker.oscog-eem.331 uuid:
>> 37d2e4b0-2f37-4e2d-8313-c63637785e59 Aug 22 2013
>> StackToRegisterMappingCogit VMMaker.oscog-eem.333 uuid:
>> 84da9cb8-7f30-4cb7-b4fb-239a11f63b54 Aug 22 2013
>>
>> On Wed, Feb 4, 2015 at 2:59 AM, Ben Coman <btc at openinworld.com> wrote:
>>
>>> In the interest of teaching how to fish, look at the senders of #roundTo:
>>> to find its usage.
>>>
>>> I'll post a full answer tomorrow if you don't beat me to it.
>>>
>>> cheers -ben
>>>
>>> On Wed, Feb 4, 2015 at 4:34 PM, Chuck Hipschman <ckhipschman at gmail.com>
>>> wrote:
>>>
>>>> 7 / 8.0 roundTo: 2 I expect 0.88, I get 0
>>>>
>>>> What am I doing wrong, or this a bug?
>>>>
>>>> TIA
>>>>
>>>> Chuck
>>>>
>>>> _______________________________________________
>>>> Beginners mailing list
>>>> Beginners at lists.squeakfoundation.org
>>>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> Beginners at lists.squeakfoundation.org
>>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>>>
>>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>>
>>
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:Lou at Keystone-Software.com http://www.Keystone-Software.com



More information about the Beginners mailing list