473,473 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

possible loss of precision

228 New Member
1: where do i lose precision? everythink is long i dont multiply so its
not posible to get enything different then long
2: how to fix it?
Expand|Select|Wrap|Line Numbers
  1.        long n,i;
  2.         long [] numbers = new long[100];
  3.         n=1;
  4.         i = 1;
  5.         numbers[n] = i;
  6.  
thanks a lot
jx2
Mar 13 '08 #1
1 7352
JosAH
11,448 Recognized Expert MVP
1: where do i lose precision? everythink is long i dont multiply so its
not posible to get enything different then long
2: how to fix it?
Expand|Select|Wrap|Line Numbers
  1.        long n,i;
  2.         long [] numbers = new long[100];
  3.         n=1;
  4.         i = 1;
  5.         numbers[n] = i;
  6.  
thanks a lot
jx2
Arrays are indexed by ints; in line 5 you're using a long for an index value so it
is cast back to int which is a narrowing implicit cast, hence the compiler diagnostic.

kind regards,

Jos
Mar 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Brian van den Broek | last post by:
Hi all, I guess it is more of a maths question than a programming one, but it involves use of the decimal module, so here goes: As a self-directed learning exercise I've been working on a...
16
by: BigMan | last post by:
How can I check if assignment of a float to a double (or vice versa) will result in loss of precision?
5
by: DAVID SCHULMAN | last post by:
I've been trying to perform a calculation that has been running into an underflow (insufficient precision) problem in Microsoft Excel, which calculates using at most 15 significant digits. For this...
4
by: hunt n peck | last post by:
does anyone know why this expression: str(csng(18333.332)) equals: "18333.33" ? why am i losing precision from this operation?
15
by: giff | last post by:
Hi all, I have a doubt, I'll try to expose it to you as clearly as I can, maybe it is not completely in topic, sorry about that. I have a few vectors of doubles (output of some calculations)...
28
by: beach.dk | last post by:
Hi, I'm trying to implement a simple hash algorith called rs_hash in javascript, but I cannot get a correct result. In c the code looks like this:
1
by: dissectcode | last post by:
Hello - I am looking at a scanf function that takes in a 16 bit unsigned int(UINT16), but its format specifier is %hd. According to ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
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...
0
tracyyun
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...
1
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.