POV-Ray : Newsgroups : povray.programming : POV-Ray 3.5 for AmigaOS : Re: Bah. Server Time
3 Jul 2024 05:37:20 EDT (-0400)
  Re: Bah.  
From: Wolfgang Wieser
Date: 10 Jul 2004 18:46:12
Message: <40f071b3@news.povray.org>
Slime wrote:

>> (classes and template parameters). However, I don't think anyone is
>> interested in another C++ lecture of mine... :P
> 
> On the contrary, I like reading them =)
> 
> Wouldn't the real C++ way be something like
> 
> reinterpret_cast<int>(some_double)
> 
> Or something like that? Not sure what type of cast it would be.
> 
The "correct C++ way" would be to use static_cast<int>(). 

This is because reinterpret_cast<>() will not change the binary 
representation while doing the cast (and is hence meant for potentially 
dangerous casts). Since casting a double into an int does require 
a change in the binary representation (usually 8 byte floating point 
into 4 byte integer), reinterpret_cast<>() cannot be applied. 
The compiler should give an error in this case. 

Wolfgang


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.