digitalmars.D.learn - Help: Types Conversion libraries, where are thou?
- jicman (41/41) Jul 22 2005 Greetings!
- Holger (4/45) Jul 22 2005 Well, how about simply using the cast() operator?
- David L. Davis (59/100) Jul 22 2005 josé, to compile using the std.boxer you should always use the "-release...
- jicman (3/116) Jul 22 2005 Thanks David.
Greetings!
Yes, it's me, your favorite Dominican learning D. :-)
Ok, so I need to change reals to integers and integers to real, int to long,
etc. I have search through digitalmars.com and found nothing about this. I did
see the phobos std.boxer, which is not working for me. For example, this
program,
import std.stdio;
import std.math;
import std.string;
import std.boxer;
real toReal(int i)
{
Box b = box(i);
real r = unbox!(real)(b);
return r;
}
int toInt(real r)
{
Box b = box(r);
int i = unbox!(int)(b);
return i;
}
void main()
{
int i = 45;
real r = 12.45;
writefln(i," ",r);
writefln(toReal(i)," ",toInt(r));
}
does not compile. Here is the error:
jic 19:08:52-> build totypes.d
c:\dmd\bin\..\..\dm\bin\link.exe
totypes,totypes.exe,,user32+kernel32,totypes.def/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
totypes.obj(totypes)
Error 42: Symbol Undefined _assert_3std5boxer
--- errorlevel 1
What are the libraries that I have to do this or do I need to write my own?
thanks,
josé
Jul 22 2005
Well, how about simply using the cast() operator?
Cheers,
Holger
In article <dbrung$1t68$1 digitaldaemon.com>, jicman says...
Greetings!
Yes, it's me, your favorite Dominican learning D. :-)
Ok, so I need to change reals to integers and integers to real, int to long,
etc. I have search through digitalmars.com and found nothing about this. I did
see the phobos std.boxer, which is not working for me. For example, this
program,
import std.stdio;
import std.math;
import std.string;
import std.boxer;
real toReal(int i)
{
Box b = box(i);
real r = unbox!(real)(b);
return r;
}
int toInt(real r)
{
Box b = box(r);
int i = unbox!(int)(b);
return i;
}
void main()
{
int i = 45;
real r = 12.45;
writefln(i," ",r);
writefln(toReal(i)," ",toInt(r));
}
does not compile. Here is the error:
jic 19:08:52-> build totypes.d
c:\dmd\bin\..\..\dm\bin\link.exe
totypes,totypes.exe,,user32+kernel32,totypes.def/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
totypes.obj(totypes)
Error 42: Symbol Undefined _assert_3std5boxer
--- errorlevel 1
What are the libraries that I have to do this or do I need to write my own?
thanks,
josé
Jul 22 2005
In article <dbrung$1t68$1 digitaldaemon.com>, jicman says...
Greetings!
Yes, it's me, your favorite Dominican learning D. :-)
Ok, so I need to change reals to integers and integers to real, int to long,
etc. I have search through digitalmars.com and found nothing about this. I did
see the phobos std.boxer, which is not working for me. For example, this
program,
import std.stdio;
import std.math;
import std.string;
import std.boxer;
real toReal(int i)
{
Box b = box(i);
real r = unbox!(real)(b);
return r;
}
int toInt(real r)
{
Box b = box(r);
int i = unbox!(int)(b);
return i;
}
void main()
{
int i = 45;
real r = 12.45;
writefln(i," ",r);
writefln(toReal(i)," ",toInt(r));
}
does not compile. Here is the error:
jic 19:08:52-> build totypes.d
c:\dmd\bin\..\..\dm\bin\link.exe
totypes,totypes.exe,,user32+kernel32,totypes.def/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
totypes.obj(totypes)
Error 42: Symbol Undefined _assert_3std5boxer
--- errorlevel 1
What are the libraries that I have to do this or do I need to write my own?
thanks,
josé
josé, to compile using the std.boxer you should always use the "-release"
commandline switch...but in your conversion example above doesn't appear to need
the std.boxer for your 'int to real' / 'real to int' example.
So, I put a little something together below that I hope you'll find helpful:
Output:
---------
C:\dmd>dmd ex072205.d
C:\dmd\bin\..\..\dm\bin\link.exe ex072205,,,user32+kernel32/noi;
C:\dmd>ex072205
Normal: int=45 real=12.45
Conversion: int=45 real=12
C:\dmd>
David L.
P.S. If you're still looking into some useful functions to use with the
std.boxer module you can check out my Box-Xtras Support section (link below).
http://spottedtiger.tripod.com/D_Language/D_BoxXtras_Support_Projects_XP.html
-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
-------------------------------------------------------------------
MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
Jul 22 2005
Thanks David. josé David L. Davis says...In article <dbrung$1t68$1 digitaldaemon.com>, jicman says...Greetings! Yes, it's me, your favorite Dominican learning D. :-) Ok, so I need to change reals to integers and integers to real, int to long, etc. I have search through digitalmars.com and found nothing about this. I did see the phobos std.boxer, which is not working for me. For example, this program, import std.stdio; import std.math; import std.string; import std.boxer; real toReal(int i) { Box b = box(i); real r = unbox!(real)(b); return r; } int toInt(real r) { Box b = box(r); int i = unbox!(int)(b); return i; } void main() { int i = 45; real r = 12.45; writefln(i," ",r); writefln(toReal(i)," ",toInt(r)); } does not compile. Here is the error: jic 19:08:52-> build totypes.d c:\dmd\bin\..\..\dm\bin\link.exe totypes,totypes.exe,,user32+kernel32,totypes.def/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved totypes.obj(totypes) Error 42: Symbol Undefined _assert_3std5boxer --- errorlevel 1 What are the libraries that I have to do this or do I need to write my own? thanks, joséjosé, to compile using the std.boxer you should always use the "-release" commandline switch...but in your conversion example above doesn't appear to need the std.boxer for your 'int to real' / 'real to int' example. So, I put a little something together below that I hope you'll find helpful: Output: --------- C:\dmd>dmd ex072205.d C:\dmd\bin\..\..\dm\bin\link.exe ex072205,,,user32+kernel32/noi; C:\dmd>ex072205 Normal: int=45 real=12.45 Conversion: int=45 real=12 C:\dmd> David L. P.S. If you're still looking into some useful functions to use with the std.boxer module you can check out my Box-Xtras Support section (link below). http://spottedtiger.tripod.com/D_Language/D_BoxXtras_Support_Projects_XP.html ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
Jul 22 2005









Holger <Holger_member pathlink.com> 