July 12, 2010
W dniu 2010-07-11 23:39, aarti_pl pisze:
> W dniu 2010-07-11 22:45, "Jérôme M. Berger" pisze:
>> aarti_pl wrote:
>>> I just would like to say that it is a great news! After discovering that
>>> for Java:
>>> ----
>>> double sum = 0.0;
>>> for (int i = 0; i< 10; i++) sum += 0.1;
>>> ----
>>>
>>> sum is equal: 0.9999999999999999
>>>
>>> I am looking at D with greater and greater sentiment :-) SWT and good
>>> precision of calculations is necessary for my program...
>>>
>> Are you sure D is better? In C, you get 0.99999999999999988898 (not
>> surprising since 0.1 cannot be represented exactly in base 2) and I
>> would expect D to give the same result...
>>
>> Jerome
>
> On my computer it is exactly 1.0 (one).
>
> I know that there is explanation of why it is like that, as I found
> article about it. I did not get deeper into it (good few pages of text)
> as I believe there must better solution for programmers.
>
> My calculator shows proper results, spreadsheet shows proper results and
> I think that calculations in my program for such a big fractions should
> also give correct result.
>
> Just thought: maybe calculations in D are done internally in more than
> 64bits and then casted into 64bits? It's a bit surprising for me that C
> is also wrong about this sum...
>
> BR
> Marcin Kuszczak
> (aarti_pl)

Ok. You are right. D is not better in this case. It seems that it's just writeln cut number of decimal digits and printed 1.

Using:
writefln("%.25f", sum);

we get:
0.99999999999999988897

Does it mean that the only way to get better precision is to use some custom classes like BigDecimal in Java?

BR
Marcin Kuszczak
(aarti_pl)
July 12, 2010
aarti_pl wrote:
> W dniu 2010-07-11 23:39, aarti_pl pisze:
>> W dniu 2010-07-11 22:45, "Jérôme M. Berger" pisze:
>>> aarti_pl wrote:
>>>> I just would like to say that it is a great news! After discovering
>>>> that
>>>> for Java:
>>>> ----
>>>> double sum = 0.0;
>>>> for (int i = 0; i< 10; i++) sum += 0.1;
>>>> ----
>>>>
>>>> sum is equal: 0.9999999999999999
>>>>
>>>> I am looking at D with greater and greater sentiment :-) SWT and good precision of calculations is necessary for my program...
>>>>
>>> Are you sure D is better? In C, you get 0.99999999999999988898 (not surprising since 0.1 cannot be represented exactly in base 2) and I would expect D to give the same result...
>>>
>>> Jerome
>>
>> On my computer it is exactly 1.0 (one).
>>
>> I know that there is explanation of why it is like that, as I found article about it. I did not get deeper into it (good few pages of text) as I believe there must better solution for programmers.
>>
>> My calculator shows proper results, spreadsheet shows proper results and I think that calculations in my program for such a big fractions should also give correct result.
>>
>> Just thought: maybe calculations in D are done internally in more than 64bits and then casted into 64bits? It's a bit surprising for me that C is also wrong about this sum...
>>
>> BR
>> Marcin Kuszczak
>> (aarti_pl)
> 
> Ok. You are right. D is not better in this case. It seems that it's just writeln cut number of decimal digits and printed 1.
> 
> Using:
> writefln("%.25f", sum);
> 
> we get:
> 0.99999999999999988897
> 
> Does it mean that the only way to get better precision is to use some custom classes like BigDecimal in Java?
> 
	AFAIK, yes. The problem is that 0.1 cannot be represented exactly
in base 2, no matter what precision you use. So your choices are
(from fastest to slowest):

- decide that the precision of a double is enough for your application after all;

- use some arbitrary precision library like gmp to increase precision, being aware that no matter how much you increase the precision, the loop above will *never* give 1 (although it can come close enough that conversion to a double will give 1)

- use some symbolic computations library. This will give you absolute precision, but may be slow and won't always give you a numerical result, i.e sqrt(2) is sqrt(2) and that's that, if you try to get a numerical result out of it, then you wind up with the same limitations as the other solutions.

		Jerome
-- 
mailto:jeberger@free.fr
http://jeberger.free.fr
Jabber: jeberger@jabber.fr



July 12, 2010
On 11.07.2010 20:30, Jacob Carlborg wrote:
> On 2010-07-11 19.09, torhu wrote:
>>  On 22.06.2010 14:49, Jacob Carlborg wrote:
>>>  On 2010-06-22 01:40, torhu wrote:
[...]
>>  I've set up my own project on Bitbucket. I've made enough changes to
>>  build my DWT app on Windows, and it's works like a charm. A lot of the
>>  Phobos code was already there, and I've added what was needed for my
>>  use. Since DWT enforces that all GUI code is run in the same thread
>>  (usually the main thread), I didn't need to add shared and __gshared
>>  that many places.
>>
>>  I had to add a lot of casts because D2 compilers are stricter about
>>  narrowing conversions. In some places Java's char type was kept as char,
>>  and not changed into wchar. I've changed the ones I came across to
>>  wchar, to avoid truncating code points that are outside of ASCII. Some
>>  conversions between char[] and wchar had to be added.
>>
>>  The String alias is D2 string, which works just fine.
>>
>>  http://bitbucket.org/torhus/dwt2
>
> So this is working with D2? If that's the case then it's great news.
> I've also found two other guys who want to work on DWT2 so this is
> starting to look pretty promising. Are your fork windows only? Have you
> looked anything on the linux port? I'll try to have a look at your
> branch and see if I can merge it with the main branch.
>
> I'm also thinking that we may need to organize our self a bit so we
> don't work on the same things.

I've only looked at the Windows version, so if anyone else wants to work on the other platforms, feel free.

At the moment my fork won't compile as D1 code, but that's easy to fix.  I didn't take a very systematic approach to the porting, since I didn't know how much work it would take or how it would work out.  You are welcome to review my changes and make suggestions.

There were some methods that were synchronized in a couple of the java.* modules.  I removed synchronized from their declaration, since D2 doesn't accept this when the methods override superclass or interface methods that are not synchronized.  I can't recall the details, but I think it looked like synchronized implies shared, meaning it changes the type of the method.  They are not synchronized in the Java version of the code, so I don't know why they were in the D code.
July 12, 2010
On Mon, Jul 12, 2010 at 11:21 AM, torhu <no@spam.invalid> wrote:
> On 11.07.2010 20:30, Jacob Carlborg wrote:
>>
>> On 2010-07-11 19.09, torhu wrote:
>>>
>>>  On 22.06.2010 14:49, Jacob Carlborg wrote:
>>>>
>>>>  On 2010-06-22 01:40, torhu wrote:
>
> [...]
>>>
>>>  I've set up my own project on Bitbucket. I've made enough changes to  build my DWT app on Windows, and it's works like a charm. A lot of the  Phobos code was already there, and I've added what was needed for my  use. Since DWT enforces that all GUI code is run in the same thread  (usually the main thread), I didn't need to add shared and __gshared  that many places.
>>>
>>>  I had to add a lot of casts because D2 compilers are stricter about  narrowing conversions. In some places Java's char type was kept as char,  and not changed into wchar. I've changed the ones I came across to  wchar, to avoid truncating code points that are outside of ASCII. Some  conversions between char[] and wchar had to be added.
>>>
>>>  The String alias is D2 string, which works just fine.
>>>
>>>  http://bitbucket.org/torhus/dwt2
>>
>> So this is working with D2? If that's the case then it's great news. I've also found two other guys who want to work on DWT2 so this is starting to look pretty promising. Are your fork windows only? Have you looked anything on the linux port? I'll try to have a look at your branch and see if I can merge it with the main branch.
>>
>> I'm also thinking that we may need to organize our self a bit so we don't work on the same things.
>
> I've only looked at the Windows version, so if anyone else wants to work on the other platforms, feel free.
>
> At the moment my fork won't compile as D1 code, but that's easy to fix.  I didn't take a very systematic approach to the porting, since I didn't know how much work it would take or how it would work out.  You are welcome to review my changes and make suggestions.
>
> There were some methods that were synchronized in a couple of the java.* modules.  I removed synchronized from their declaration, since D2 doesn't accept this when the methods override superclass or interface methods that are not synchronized.  I can't recall the details, but I think it looked like synchronized implies shared, meaning it changes the type of the method.  They are not synchronized in the Java version of the code, so I don't know why they were in the D code.
>

Being one of the guys Jacob mentioned, wanted to chime in and second his thoughts - this is cool, we need to coordinate, etc.  I haven't had much time to work on this yet, but it looks like most of my changes parallel yours.  I started by getting (most) things to work with D1/Tango first, and got most of the snippets working on Windows... was waiting to make sure I didn't break anything for the Linux build before saying anything.

Encountered the same thing with synchronized you did, but my solution was simply to move to a synchronized block surrounding the method body.  Didn't examine why things were synchronized, but according to what I've read D will treat a "synchronized { foo }" block like a block on the object, which is the same as the synchronized tag on a method in Java.  Didn't check the original Java code though...

What are your thoughts on how we should coordinate efforts?  I'm mostly interested in doing D2/Phobos work, but have a setup where I can (relatively) easily switch between to make sure things work w/ Tango and D2.

Jeremy
July 12, 2010
On 13.07.2010 00:01, Jeremy Powers wrote:
[snip]
> Being one of the guys Jacob mentioned, wanted to chime in and second
> his thoughts - this is cool, we need to coordinate, etc.  I haven't
> had much time to work on this yet, but it looks like most of my
> changes parallel yours.  I started by getting (most) things to work
> with D1/Tango first, and got most of the snippets working on
> Windows... was waiting to make sure I didn't break anything for the
> Linux build before saying anything.
>
> Encountered the same thing with synchronized you did, but my solution
> was simply to move to a synchronized block surrounding the method
> body.  Didn't examine why things were synchronized, but according to
> what I've read D will treat a "synchronized { foo }" block like a
> block on the object, which is the same as the synchronized tag on a
> method in Java.  Didn't check the original Java code though...

We should probably check out if any part of DWT actually need those methods to be synchronized.  I removed synchronized because it seemed the cleaner solution, but yours is obviously safer.

>
> What are your thoughts on how we should coordinate efforts?  I'm
> mostly interested in doing D2/Phobos work, but have a setup where I
> can (relatively) easily switch between to make sure things work w/
> Tango and D2.

For me cooperation would have to be pretty loose, as I don't know how much more time I'll spend on this now that I've got enough ported to make my own app work with D2.  It's possible that a lot of what is needed is deciding how to solve the various issues that crop up, maybe more than actual editing of code.  We could just use this newsgroup for that, I suppose.  Or the DWT forum on dsource.org if that's what people prefer.

One issue is what to do with the snippets? Making them work with both D1 and D2 would make a lot of them ugly.  Is that worth it, do we add a simple compatibility wrapper module, or what?  And what about the larger examples that are still missing from DWT2?
July 13, 2010
On 2010-07-13 00.01, Jeremy Powers wrote:
> On Mon, Jul 12, 2010 at 11:21 AM, torhu<no@spam.invalid>  wrote:
>> On 11.07.2010 20:30, Jacob Carlborg wrote:
>>>
>>> On 2010-07-11 19.09, torhu wrote:
>>>>
>>>>   On 22.06.2010 14:49, Jacob Carlborg wrote:
>>>>>
>>>>>   On 2010-06-22 01:40, torhu wrote:
>>
>> [...]
>>>>
>>>>   I've set up my own project on Bitbucket. I've made enough changes to
>>>>   build my DWT app on Windows, and it's works like a charm. A lot of the
>>>>   Phobos code was already there, and I've added what was needed for my
>>>>   use. Since DWT enforces that all GUI code is run in the same thread
>>>>   (usually the main thread), I didn't need to add shared and __gshared
>>>>   that many places.
>>>>
>>>>   I had to add a lot of casts because D2 compilers are stricter about
>>>>   narrowing conversions. In some places Java's char type was kept as char,
>>>>   and not changed into wchar. I've changed the ones I came across to
>>>>   wchar, to avoid truncating code points that are outside of ASCII. Some
>>>>   conversions between char[] and wchar had to be added.
>>>>
>>>>   The String alias is D2 string, which works just fine.
>>>>
>>>>   http://bitbucket.org/torhus/dwt2
>>>
>>> So this is working with D2? If that's the case then it's great news.
>>> I've also found two other guys who want to work on DWT2 so this is
>>> starting to look pretty promising. Are your fork windows only? Have you
>>> looked anything on the linux port? I'll try to have a look at your
>>> branch and see if I can merge it with the main branch.
>>>
>>> I'm also thinking that we may need to organize our self a bit so we
>>> don't work on the same things.
>>
>> I've only looked at the Windows version, so if anyone else wants to work on
>> the other platforms, feel free.
>>
>> At the moment my fork won't compile as D1 code, but that's easy to fix.  I
>> didn't take a very systematic approach to the porting, since I didn't know
>> how much work it would take or how it would work out.  You are welcome to
>> review my changes and make suggestions.
>>
>> There were some methods that were synchronized in a couple of the java.*
>> modules.  I removed synchronized from their declaration, since D2 doesn't
>> accept this when the methods override superclass or interface methods that
>> are not synchronized.  I can't recall the details, but I think it looked
>> like synchronized implies shared, meaning it changes the type of the method.
>>   They are not synchronized in the Java version of the code, so I don't know
>> why they were in the D code.
>>
>
> Being one of the guys Jacob mentioned, wanted to chime in and second
> his thoughts - this is cool, we need to coordinate, etc.  I haven't
> had much time to work on this yet, but it looks like most of my
> changes parallel yours.  I started by getting (most) things to work
> with D1/Tango first, and got most of the snippets working on
> Windows... was waiting to make sure I didn't break anything for the
> Linux build before saying anything.
>
> Encountered the same thing with synchronized you did, but my solution
> was simply to move to a synchronized block surrounding the method
> body.  Didn't examine why things were synchronized, but according to
> what I've read D will treat a "synchronized { foo }" block like a
> block on the object, which is the same as the synchronized tag on a
> method in Java.  Didn't check the original Java code though...
>
> What are your thoughts on how we should coordinate efforts?  I'm
> mostly interested in doing D2/Phobos work, but have a setup where I
> can (relatively) easily switch between to make sure things work w/
> Tango and D2.
>
> Jeremy

I think what's most important is that we don't work on the same code, we don't want ones work to render any other work unusable. I'll probably focus on finishing the Mac port in the dwt-mac repository, merge changes to the repository and coordinate things. Then I'll add the Mac port to the DWT2 repository. I'll probably use D1 and Tango for most of the time.

-- 
Jacob Carlborg
July 13, 2010
On 2010-07-13 01.20, torhu wrote:
> On 13.07.2010 00:01, Jeremy Powers wrote:
> [snip]
>> Being one of the guys Jacob mentioned, wanted to chime in and second
>> his thoughts - this is cool, we need to coordinate, etc. I haven't
>> had much time to work on this yet, but it looks like most of my
>> changes parallel yours. I started by getting (most) things to work
>> with D1/Tango first, and got most of the snippets working on
>> Windows... was waiting to make sure I didn't break anything for the
>> Linux build before saying anything.
>>
>> Encountered the same thing with synchronized you did, but my solution
>> was simply to move to a synchronized block surrounding the method
>> body. Didn't examine why things were synchronized, but according to
>> what I've read D will treat a "synchronized { foo }" block like a
>> block on the object, which is the same as the synchronized tag on a
>> method in Java. Didn't check the original Java code though...
>
> We should probably check out if any part of DWT actually need those
> methods to be synchronized. I removed synchronized because it seemed the
> cleaner solution, but yours is obviously safer.

Yes, we need to look into this.

>>
>> What are your thoughts on how we should coordinate efforts? I'm
>> mostly interested in doing D2/Phobos work, but have a setup where I
>> can (relatively) easily switch between to make sure things work w/
>> Tango and D2.
>
> For me cooperation would have to be pretty loose, as I don't know how
> much more time I'll spend on this now that I've got enough ported to
> make my own app work with D2. It's possible that a lot of what is needed
> is deciding how to solve the various issues that crop up, maybe more
> than actual editing of code. We could just use this newsgroup for that,
> I suppose. Or the DWT forum on dsource.org if that's what people prefer.

When we coordinate things I just want to make sure we're not working on the same code, for example, we don't want ones work to render any other work unusable.

> One issue is what to do with the snippets? Making them work with both D1
> and D2 would make a lot of them ugly. Is that worth it, do we add a
> simple compatibility wrapper module, or what? And what about the larger
> examples that are still missing from DWT2?

I don't know how much of the runtime library is used in the snippets, how much will need to be changed to make it work with both D1 and D2. There are already runtime independent functions in DWT hopefully most of them can be used.

-- 
Jacob Carlborg
July 28, 2010
when i do:
$ hg log -r -1 rpmbuild/SOURCES/dwt-linux/
changeset:   364:2bcb17ebe0be
tag:         tip
user:        Frank Benoit <benoit@tionex.de>
date:        Sun Nov 08 20:57:46 2009 +0100
summary:     fix: thx torhu
______________________________________

So dwt project is die for linux?
i am fedora packager and i would like packaget it, but not a project where is die!
July 28, 2010
ok on http://www.dsource.org/projects/dwt link is:
hg clone http://hg.dsource.org/projects/dwt2
but website is not up to date
hg clone http://bitbucket.org/torhus/dwt2

Someone can update please this website thanks
1 2 3
Next ›   Last »