Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread RuZzz via Digitalmars-d-learn
Thanks. Do I need to use rational fractions for the Currencies class?

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread RuZzz via Digitalmars-d-learn
On Saturday, 31 January 2015 at 15:02:09 UTC, Colin wrote: Maybe you can articulate it in one post what this class is trying to achieve? Maybe this? https://github.com/andersonpd/decimal/blob/master/decimal/bigfloat.d The main thing is not to lose currency in calculations that use arithmetic.

Re: Labels in struct

2015-01-31 Thread tcak via Digitalmars-d-learn
On Saturday, 31 January 2015 at 16:04:36 UTC, tcak wrote: I do not have a big example in the end to show, but is there any way to put labels into struct definitions? struct CommunicationMessage{ char[2] signature; mainData: int info1; int info2; extraData: ushort checksum;

Re: Labels in struct

2015-01-31 Thread Adam D. Ruppe via Digitalmars-d-learn
You could use a UDA like that, though getting the offset will be a bit tricky. The idea is to use some uda type, even plain string is good enough, then use the __traits to find the first appearance of that UDA in the object and return that offset. Keep in mind that the @uda: syntax applies

Re: Labels in struct

2015-01-31 Thread Adam D. Ruppe via Digitalmars-d-learn
Oh this hack also won't work with a label at the very end. You could use sizeof for that though (however that would include padding bytes. Perhaps last member's offsetof plus last member's sizeof is a bit more accurate.)

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread RuZzz via Digitalmars-d-learn
The next version, which does not work: https://bpaste.net/show/b9c85de68d07

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread zeljkog via Digitalmars-d-learn
On 31.01.15 15:45, RuZzz wrote: Maybe I need good examples on C++, for this class, because a lot of examples on C++. Maybe this can help you: https://github.com/andersonpd/decimal

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread RuZzz via Digitalmars-d-learn
I want to understand the correct architecture of the class.

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 31 January 2015 at 13:45:22 UTC, RuZzz wrote: I want to understand the correct architecture of the class. Sorry, you still did not state your problem (or what you are trying to achieve) clearly. Writing down a clear problem description is likely to get you halfway to the

Error when profiling

2015-01-31 Thread Phil via Digitalmars-d-learn
When trying to run my program with profiling enabled it dies before the first line of my main function runs. Everything works fine without profiling. I get the following stack trace: thread #1: tid = 0x38de4, 0x00010008d985 vision_entry`gc_malloc + 49, queue = 'com.apple.main-thread',

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread zeljkog via Digitalmars-d-learn
On 31.01.15 15:56, zeljkog wrote: On 31.01.15 15:45, RuZzz wrote: Maybe I need good examples on C++, for this class, because a lot of examples on C++. Maybe this can help you: https://github.com/andersonpd/decimal Also http://code.dlang.org/packages/eris

Labels in struct

2015-01-31 Thread tcak via Digitalmars-d-learn
I do not have a big example in the end to show, but is there any way to put labels into struct definitions? struct CommunicationMessage{ char[2] signature; mainData: int info1; int info2; extraData: ushort checksum; content: } Example I defined something like above. I am

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread RuZzz via Digitalmars-d-learn
Maybe I need good examples on C++, for this class, because a lot of examples on C++.

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread RuZzz via Digitalmars-d-learn
I am looking for not only free solutions.

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread Colin via Digitalmars-d-learn
On Saturday, 31 January 2015 at 14:26:45 UTC, RuZzz wrote: The next version, which does not work: https://bpaste.net/show/b9c85de68d07 I really dont understand what your trying to achieve here. Maybe you can articulate it in one post what this class is trying to achieve?

Re: Labels in struct

2015-01-31 Thread Artur Skawina via Digitalmars-d-learn
On 01/31/15 17:04, tcak via Digitalmars-d-learn wrote: struct CommunicationMessage{ [...] content: } Example I defined something like above. I am using it as a base structure, and don't know how long the content of message will be. But I know that it will be at the end. I could use

Re: Labels in struct

2015-01-31 Thread zeljkog via Digitalmars-d-learn
On 31.01.15 17:04, tcak wrote: I do not have a big example in the end to show, but is there any way to put labels into struct definitions? struct CommunicationMessage{ char[2] signature; mainData: int info1; int info2; extraData: ushort checksum; content: } Members of

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread RuZzz via Digitalmars-d-learn
The next version https://bpaste.net/show/9468f24d9df0

Re: foreach - premature optimization vs cultivating good habits

2015-01-31 Thread via Digitalmars-d-learn
On Friday, 30 January 2015 at 14:41:11 UTC, Laeeth Isharc wrote: Thanks, Adam. That's what I had thought (your first paragraph), but something Ola on a different thread confused me and made me think I didn't understand it, and I wanted to pin it down. There is always significant

windows wininet library

2015-01-31 Thread ketmar via Digitalmars-d-learn
how can i use wininet.dll from D? i got bindings from https://github.com/ CS-svnmirror/dsource-bindings-win32.git, and then i tried to create wininet.lib with implib.exe from DMC package. no matter how i tried, the resulting wininet.lib seems to not work, as linker keep complaining about

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread RuZzz via Digitalmars-d-learn
How to get amount of digit after point in a double for to get integer from a double? assert(amountAfterPoint(1.456) == 3); assert(amountAfterPoint(0.6) == 5);

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread RuZzz via Digitalmars-d-learn
without to!string

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread Colin via Digitalmars-d-learn
On Saturday, 31 January 2015 at 12:07:23 UTC, RuZzz wrote: How to get amount of digit after point in a double for to get integer from a double? assert(amountAfterPoint(1.456) == 3); assert(amountAfterPoint(0.6) == 5); How about a loop like import std.stdio; void main(){