Re: Recovering D1 Code from .obj or .exe files

2009-11-04 Thread mpt
jicman wrote: Greetings! I need your help, if so at all possible... I just lost lots of code changes because a computer lock down, but I have a good .exe file with .obj and also .exe files. Is there a possibility to grab the code from those files? Or, is there any way that I can

Re: cast(int) getting an unexpected number

2009-11-04 Thread Steven Schveighoffer
On Wed, 04 Nov 2009 06:14:36 -0500, Joel Christensen joel...@gmail.com wrote: Input: import std.stdio; void main() { float f=0.01; writefln(%0.2f-%d,f,cast(int)(f*100f)); } Output: 0.01-0 Comment: What!? hehe. .01 is not exactly represented by float, because it's stored

Re: cast(int) getting an unexpected number

2009-11-04 Thread rmcguire
Steven Schveighoffer schvei...@yahoo.com wrote: On Wed, 04 Nov 2009 06:14:36 -0500, Joel Christensen joel...@gmail.com wrote: Input: import std.stdio; void main() { float f=0.01; writefln(%0.2f-%d,f,cast(int)(f*100f)); } Output: 0.01-0 Comment: What!? hehe. .01 is not

Re: cast(int) getting an unexpected number

2009-11-04 Thread Michal Minich
Hello rmcguire, why is this not a compiler bug? because: import std.stdio; void main() { float f=0.01; writefln(%0.2f-%d,f,cast(int)(f*100f)); writefln(%0.2f-%d,f,cast(int)(.01*100f)); writefln(%0.2f-%f,f,(f*100f)); } results in: 0.01-0 0.01-1 0.01-1.00 I would say something is dodgy.

Re: cast(int) getting an unexpected number

2009-11-04 Thread Lars T. Kyllingstad
Michal Minich wrote: Hello rmcguire, why is this not a compiler bug? because: import std.stdio; void main() { float f=0.01; writefln(%0.2f-%d,f,cast(int)(f*100f)); writefln(%0.2f-%d,f,cast(int)(.01*100f)); writefln(%0.2f-%f,f,(f*100f)); } results in: 0.01-0 0.01-1 0.01-1.00 I would say

Re: cast(int) getting an unexpected number

2009-11-04 Thread Charles Hixson
Lars T. Kyllingstad wrote: Michal Minich wrote: Hello rmcguire, why is this not a compiler bug? because: import std.stdio; void main() { float f=0.01; writefln(%0.2f-%d,f,cast(int)(f*100f)); writefln(%0.2f-%d,f,cast(int)(.01*100f)); writefln(%0.2f-%f,f,(f*100f)); } results in: 0.01-0 0.01-1

Re: cast(int) getting an unexpected number

2009-11-04 Thread Lars T. Kyllingstad
Charles Hixson wrote: Lars T. Kyllingstad wrote: Michal Minich wrote: Hello rmcguire, why is this not a compiler bug? because: import std.stdio; void main() { float f=0.01; writefln(%0.2f-%d,f,cast(int)(f*100f)); writefln(%0.2f-%d,f,cast(int)(.01*100f)); writefln(%0.2f-%f,f,(f*100f)); }

Re: cast(int) getting an unexpected number

2009-11-04 Thread Ali Cehreli
Ok, I messed up my previous comment while moving rmcguire's lines around. Trying again... Also, I am not sure about the last bit now. :) rmcguire Wrote: why is this not a compiler bug? because: import std.stdio; void main() { float f=0.01; Just an information: 0.01 is double,

asserts in debug and release code

2009-11-04 Thread Justin Johansson
With respect to the dmd -release compiler switch, are assert statements meant to be compiled in release code? Whilst the D1 spec says The compiler may optionally not evaluate assert expressions at all., my intuition suggests that asserts would/should be evaluated (i.e. compiled in) when using

Re: asserts in debug and release code

2009-11-04 Thread BCS
Hello Justin, With respect to the dmd -release compiler switch, are assert statements meant to be compiled in release code? Whilst the D1 spec says The compiler may optionally not evaluate assert expressions at all., my intuition suggests that asserts would/should be evaluated (i.e. compiled

char* to string

2009-11-04 Thread BLS
HI, I would like to use some pbobos string based functions within an DLL. Unfortunately all I can do is to pass char* parameters from the callee side. Now I want to use f.i. std.regex export extern(windows) char* xxx() //Heck were is Jarret when I need him most ? D2,beside Björn

Re: char* to string

2009-11-04 Thread BLS
On 05/11/2009 00:11, BLS wrote: char* xxx() better char* xxx(char* a, char* b) { string A = }

gap buffer in D2

2009-11-04 Thread BLS
yep, mean it... has somebody done it before...to me it seems to be not as trivial as it looks on the very first view. (speed matters)

Re: gap buffer in D2

2009-11-04 Thread Spacen Jasset
BLS wrote: yep, mean it... has somebody done it before...to me it seems to be not as trivial as it looks on the very first view. (speed matters) Did one in C once for an editor (of course). Does that count? I might be able to find the code. It might not be pretty I can't remember.

Re: gap buffer in D2

2009-11-04 Thread BLS
On 05/11/2009 01:04, Spacen Jasset wrote: BLS wrote: yep, mean it... has somebody done it before...to me it seems to be not as trivial as it looks on the very first view. (speed matters) Did one in C once for an editor (of course). Does that count? I might be able to find the code. It might

Re: cast(int) getting an unexpected number

2009-11-04 Thread Joel Christensen
To be safe, whenever converting to int, always add a small epsilon. I think you can use float.epsilon, but I don't have any experience with whether that is always reasonable. -Steve Thanks every one for the replies. I still have problems. How do I use epsilon? 'real' helps in my example