Re: Which function returns a pair after division ? (integer,frac)

2023-09-18 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Tuesday, 19 September 2023 at 03:53:06 UTC, Richard (Rikki) Andrew Cattermole wrote: There are no operators for this, not that you need one. ```d void func(int numerator, int denominator, out int quotient, out int remainder) { quotient = numerator / denominator; remainder =

Re: Which function returns a pair after division ? (integer,frac)

2023-09-18 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
There are no operators for this, not that you need one. ```d void func(int numerator, int denominator, out int quotient, out int remainder) { quotient = numerator / denominator; remainder = numerator % denominator; } ``` This will produce with ldc2 -O3: ``` void example.func(int,

Re: Which function returns a pair after division ? (integer,frac)

2023-09-18 Thread Ki Rill via Digitalmars-d-learn
On Tuesday, 19 September 2023 at 03:44:18 UTC, Vitaliy Fadeev wrote: What D function or D operator does this? ```asm IDIV EAX, r/m32 ``` ``` IDIV 5, 2 EAX = 2 EDX = 1 ``` and returns (2,1) at once? You can either use function `out` parameters with return value or `tuples`: ```D import

Which function returns a pair after division ? (integer,frac)

2023-09-18 Thread Vitaliy Fadeev via Digitalmars-d-learn
What D function or D operator does this? ```asm IDIV EAX, r/m32 ``` ``` IDIV 5, 2 EAX = 2 EDX = 1 ``` and returns (2,1) at once?

container vs standard array

2023-09-18 Thread vino via Digitalmars-d-learn
Hi All, I am trying to understand as to why the below code is throwing error Code ``` import std.stdio: writeln; import std.container.array; void main () { //auto a = Array!string("Aname"); // throws error auto b = Array!char("Bname");// works auto c =

Re: How to use core.vararg to print D variadic arguments and their types without using ! (template instantiation)?

2023-09-18 Thread BoQsc via Digitalmars-d-learn
'!()(__va_list_tag[1], TypeInfo, int*)' 11 | va_arg(_argptr, typeid(i), ); |^ /opt/compiler-explorer/gcc-trunk-20230918/lib/gcc/x86_64-linux-gnu/14.0.0/include/d/core/stdc/stdarg.d:179:7: note: Candidates are: 'va_arg(T)(ref va_list ap)' 179 | T va_arg(T)(ref va_list ap