I've designed a method in the class called Blopp.
class Blopp { void foo (int a = 3, double b = 3.6) {} } ;
The problem is only that when i call the method, the
value of b seems to be truncated, if one believes the
(un?) helpful IDE that pops out an info-note. On it,
the value has been clearly lowered to 3.0!
I went debugger on it and it seems that the actual
value indeed is 3.6, as supposed to. However, when
the helping info-notes give one strange suggestions,
it often implies that _something_ is wrong.
What could be a reason for this kind of behavior,
regarding the pure "C++ code"-wise. Should or need
i to use an "d" after the value to explicitly indicate
the double-ness of it? I didn't expect it to be so,
but then again, i didn't expect the truncation either...
--
Vänligen Kerstin Viltersten
(The Cool Giraffe) 2 1714
On May 25, 12:49 am, "The Cool Giraffe" <giraf...@vilte rsten.com>
wrote:
I've designed a method in the class called Blopp.
class Blopp { void foo (int a = 3, double b = 3.6) {} } ;
sorry to break the peace and quiet, but Blopp::foo(...) is private.
So please explain how and where you are calling that member function
(ie: show something that compiles).
>
The problem is only that when i call the method, the
value of b seems to be truncated, if one believes the
(un?) helpful IDE that pops out an info-note. On it,
the value has been clearly lowered to 3.0!
I went debugger on it and it seems that the actual
value indeed is 3.6, as supposed to. However, when
the helping info-notes give one strange suggestions,
it often implies that _something_ is wrong.
What could be a reason for this kind of behavior,
regarding the pure "C++ code"-wise. Should or need
i to use an "d" after the value to explicitly indicate
the double-ness of it? I didn't expect it to be so,
but then again, i didn't expect the truncation either...
That double won't get truncated, it might however get converted into
an integer depending on what you do with it. Again, show code that
compiles, otherwise we can spend the next 2 decades disscussing all
the possibilities.
The Cool Giraffe wrote:
>
I went debugger on it and it seems that the actual
value indeed is 3.6, as supposed to. However, when
the helping info-notes give one strange suggestions,
it often implies that _something_ is wrong.
What could be a reason for this kind of behavior,
regarding the pure "C++ code"-wise. Should or need
i to use an "d" after the value to explicitly indicate
the double-ness of it? I didn't expect it to be so,
but then again, i didn't expect the truncation either...
The type of 3.6 is double.
--
-- Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." ( www.petebecker.com/tr1book) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Simon |
last post by:
Hi all
I am writing a small app that uses real numbers all over the place for
calculations.
But when it comes to displaying values it is better to only display an it,
(especially when it comes to % values and so on).
so I first thought that the best way would be...
....
|
by: Bjørn Augestad |
last post by:
Below is a program which converts a double to an integer in two
different ways, giving me two different values for the int. The basic
expression is 1.0 / (1.0 * 365.0) which should be 365, but one variable
becomes 364 and the other one becomes 365.
Does anyone have any insight to what the problem is?
Thanks in advance.
Bjørn
|
by: bunty.gopal |
last post by:
I am trying to use the PreparedStatement's addBatch to load data in an
ETL-like process into a table. There is a single prepared statement.
The parameters are set on it and prepStmt.addBatch() is called. Then
the next iteration of setting the params and adding to batch begins.
Finally after setting the batch of 2 to 2000 rows, the
prepStmt.executeBatch() is called.
If the last row contains a null value for a particular DECIMAL field,...
|
by: Dilip |
last post by:
Recently in our code, I ran into a situation where were stuffing a
float inside a double. The precision was extended automatically
because of that. To make a long story short, this caused problems
elsewhere in another part of the system where that figure was used for
some calculation and some eventual truncation led to the system going
haywire. So my question is, given this code:
int main()
{
float f = 59.89F;
|
by: bunty.gopal |
last post by:
This is the solution to the issue in the subject, question itself was
posted in a previous thread long back.
Use the latest DB2 db2cc.jar fixpack on the client, or add
"deferPrepares=false" to the connection string when opening the
connection (or connection pool properties, if deployed on a server like
weblogic). The issue can be resolved using either of these options.
Gopal
| |
by: John Doe |
last post by:
I have a not-so-large double in the range 1-1000, but with fractional
part. I only do ++my_double to increment it, however sometimes it
happens that after incrementing
int(old_double) == int(new_double)
why? Again the doubles are not large at all, their exponents cannot be
so high to shift out the 1 I add out when incrementing and we have 64
bits to use here.
|
by: md |
last post by:
Hi
Does any body know, how to round a double value with a specific number
of digits after the decimal points?
A function like this:
RoundMyDouble (double &value, short numberOfPrecisions)
It then updates the value with numberOfPrecisions after the decimal
|
by: Peter Ramsebner |
last post by:
Is there an explication why it's executed the then path?
Dim a As Double = 10
Dim b As Double = 3
Dim c As Double = 3
Dim x As Double
Dim y As Double = 10
x = a / b
x *= c
If x = y Then
|
by: Nathan Sokalski |
last post by:
I know that Single and Double can only store values that can be stored as
x/2^y, such as 0.5 and 0.125. But when they attempt to store values such as
0.1 or 0.2 whose exact value cannot be stored, what algorithm do they use to
determine what value to store? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |