[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Type Casting
From: |
Geoffrey Schultz |
Subject: |
Re: Type Casting |
Date: |
Mon, 1 Jun 1998 10:51:22 -0400 (EDT) |
On Thu, 28 May 1998, Doug Donalson; wrote:
> This is really a programming question.
>
> I want to cast a double (or int) to a char. Now
> as long as it is only a single digit I thought there should
> not be a problem. (My OLD books say the same.) Actually,
> the conversion is supposed to take the lowest digit regardless
> of the numerical format.
>
Hello Doug,
I ran into a similar need in my simulation a while back and here's the
solution that's working for me:
id myXAndYLabel;
char theX[3];
char theY[3];
myXAndYLabel=[String create:[self getZone] setC: ""];
sprintf(theX,"%d",[anObject getX]);
sprintf(theY,"%d",[anObject getY]);
[myXAndYLabel appendC: theX];
[myXAndYLabel appendC: theY];
(look into the code for UName within simtools source, I found that very
helpful)
Geoff Schultz
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
==================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Type Casting,
Geoffrey Schultz <=