I'm working on a program that requires some very low level optimization. My question is, when precision isn't an important factor, how can I automatically use the most efficient floating point type for whatever architecture the program is being run on? As far as I'm aware, floats are more efficient on 32 bit systems, and doubles are more efficient on 64 bit systems. Is there some sort of keyword or macro I can use which always uses the native data type for the machine it's being run on? Thanks, appreciate any help.

Member Avatar
+0 forum 0

Hi guys, I am trying to write a program which picks the closest number possible out of a dictionary. The dictionary contains 50 doubles values, and I use a random double to pick the number i want to get the closest to if that makes sense. Currently I am using linq to pick the first one which is less or equal to the random number. The problem I have found with this is that it is not reaching numbers which are closer and its most certainly picks the same key all the time. I have also tried the SkipWhile method …

Member Avatar
Member Avatar
+0 forum 4

I'm working on a programme that's supposed to accept input of doubles from an array however it's not quite working out for me. It takes in Integers alright but not the double values. Could someone point me in the right direction Any help is much appreciated double array[] = new double[10]; int total = 0; for (int counter = 0; counter < array.length; counter++) { array[counter] = Integer.parseInt(JOptionPane.showInputDialog("Enter the figures for the array")); total= (int) (total+array[counter]); } int average = total/10; JOptionPane.showMessageDialog(null, "the total is "+total); JOptionPane.showMessageDialog(null, "the average is "+average); }

Member Avatar
Member Avatar
+0 forum 3

Hi there, i have recieved this notice Warning: Header may not contain more than a single header, new line detected in C:\xampp\htdocs\a\Student_Edit_Handler.php on line 53 and these are my codes. Kindly help me to fix this. <?php session_start(); $session_id = $_SESSION['user_id']; if($session_id == null){ header("location:Student_Edit.php"); die(); } include 'Connect.php'; $flag = "success"; function rollbackData(){ mysql_query(" ROLLBACK "); global $flag; $flag = "error"; if(mysql_error() != null){ die(mysql_error()); } } $student_id = $_POST['student_id']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $gender = $_POST['gender']; $date_of_birth = date("Y-m-d",strtotime($_POST['date_of_birth'])); $contact_no = $_POST['contact_no']; $grade = $_POST['grade']; $section = $_POST['section']; $LRN = $_POST['LRN']; $email1 = $_POST['email1']; $email2 = …

Member Avatar
+0 forum 0

In our network we have two gateways one for accessing local intranet sites and other for accessing internet.we use static routing in individual pc to access both the routes.we are facing problem that one intranet site http://np41http1.xyx.abc.co.in:8103/SAP(bD1lbiZjPTQwMCZkPW1pbg==)/ryt/default.htm .we susscessfully ping the site from ip addess and tracert is also done successfully but this site is not opening from the browser IE 8.During tracert it is also not showing the sitename but tracert comes susscessfull by ip address.i also done host entry

Member Avatar
Member Avatar
+0 forum 3

i have two different programs that compare float and double variales and gives output , i shown that below : 1. #include<stdio.h> main() { int r; float f=22.5; double d=22.5; r=(f==d); printf("r=%d",r); } **Output:- r=1** 2. #include<stdio.h> main() { int r; float f=22.7; double d=22.7; r=(f==d); printf("r=%d",r); } **Output:- r=0** why this happen that for 22.5 both are same and gives o/p 1 and 22.7 both (f & d) are different and gives o/p 0

Member Avatar
Member Avatar
+0 forum 4

Hi there, I am having a problem of passing arrays to functions, here is my code: void zeroMatrix(float **arr); void main() { float e[2][2]; zeroMatrix(e); } void zeroMatrix(float** arr) { int i,j; for (i=0;i<2;i++) { for(j=0;j<2;j++) { *( *(arr +i)+j) =0; } } } The problem is I want to allocate dynamically an array and to pass to a function. Cheers guys

Member Avatar
Member Avatar
+0 forum 5

Heelloooo good day. Thanks for seeking to help. I am creating a Java program(obviously). At the end of my work I wish to install it as (a)an .exe file. However I wish that after its installation, file type association would have been setup automatically(I phrased that latter part of the statement like that, because I'm not sure if file association can be coded, or if it must be accomplished via other tools). I have ruled out JWS(Java Web Start) though. SO once again: 1. Program must be a(an) .exe file. 2. And the installation process should seamslessly create the file …

Member Avatar
Member Avatar
+0 forum 6

Hi my name is vishal. For the past 1 week i been in the process of creating a dashboard using listview in c# windows forms with sql server 2008. I created listview named lstDashItems and populate it from a table named USERACTIVITIES in sql server 2008. The design of USERACTIVITIES table in sql server 2008. Column Name Data Type Allow Nulls user_id int yes row_upd_date datetime yes activity varchar(50) yes type int yes ref_id numeric(18,0) yes I have created a method in MdiParent Form named updateUserActivities() Given below is the code in my MdiParent Form of Method/function updateUserActivities: public void …

Member Avatar
Member Avatar
+0 forum 2

I'm designing a LongDouble datatype which take a 16 byte space. my question is how to add or substract a two double numbers correctly ex : a= 3.025466 b=4.132655`` the result will be 7.158121 but in my code it's different here is my code LongDouble LongDouble::operator+( LongDouble olong) { LongDouble temp; if (this->sign == 0 && olong.sign == 0) { temp.exponent = this->exponent + olong.exponent; for (int i = 0; i < 7; i++) temp.mantissa[i] = this->mantissa[i] + olong.mantissa[i]; if (temp.mantissa[0] > 9) { temp.exponent += 1; temp.mantissa[0]-=10; } temp.sign = 0; } if (this->sign == 1 && olong.sign == …

Member Avatar
Member Avatar
+0 forum 4

Hi everyone, I'm new in vb.Net programming and i just want to ask how to validate a "Double" data type. for example. Dim number as Double number = textbox1.text If the value of "number" variable is in "Double" data type like 1.23 or 0.12 it returns a correct value and If the value of of a "number" is like ... or .. it returns an error Conversion from string "." to type 'Double' is not valid. I tried to suppres the error using the try catch but it still return the same error

Member Avatar
Member Avatar
+0 forum 6

Hi guys, I've created a simple plugin for Wordpress that interacts with an API in the backend. The problem is that everything is inserted twice in the database, and I cannot figure out why. The form is submiting only once, not twice. What could it be ? Redirects from my .htaccess ? # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule> # END WordPress My function from the plugin, this is the logs table and after that i'm calling `get_curl_data()` function. function verifica_disponibilitate_curl($post) { $sdstr …

Member Avatar
Member Avatar
+0 forum 1

Hello everyone, I'm trying to basically get a cmd variable to pass into commands.getstatusoutput. The problem is that the command has a lot of single and double quotes in it and I can't seem to get it to store as a variable. When I print the cmd it comes out as I want it to (since I tried \ escaping one of the single quotes.. here is an example of what I'm trying to do: cmd1 = "convert -pointsize %i -fill %s -draw " % (pointsize, fill) cmd2 = ''text %d,%d "%s Hour: %i"' %s %s_cap.jpg' % (half_image, up_buff, out_month, …

Member Avatar
Member Avatar
+0 forum 5

public class homework8_2 public static void main(String [] args) { Scanner keyboard = new Scanner(System.in); int selections = 0; DecimalFormat formatter = new DecimalFormat("#0.0000"); do { showMenu(); selections = keyboard.nextInt(); System.out.println("please input the amount of meters"); double meters = keyboard.nextDouble(); if (selections == 1) { double kilometers; kilometers = showKilometers(meters); System.out.println("Kilometers = " + kilometers); } else if (selections == 2) { double inches = 0; inches = showInches(meters); System.out.println("inches = " + inches); } else if (selections == 3) { double feet = 0; feet = showFeet(meters); System.out.println("Feets = " + feet); } }while (selections != 4); } public …

Member Avatar
Member Avatar
+0 forum 6

Hi there, My issue: I have a datagridview and a DB file with ~100 columns and ~200 rows of data. This data is imported to the DGV onLoad(). Once i have the data i run a script that searchs a predefined(by the user) folder for text files. Each text file has anywhere between 2 and 100 lines of text each in the following format: CRADEG DEGREE OF CRASH 1 Fatal 2 Injury 3 Non-casualty (towaway) I can loop through the text file (ignoring the first line) and get each line of information and assign it a code (left column) and …

Member Avatar
Member Avatar
+0 forum 6

What I am trying to do is make a program that reads a txt file and converts the number into a double array. import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class rocket { public static void main(String[] args) throws IOException, FileNotFoundException { System.out.println(readLines("/Users/Jeremy/Documents/workspace/altitude.txt")); } public static Double[] readLines(String filename) throws IOException { FileReader fileReader = new FileReader(filename); BufferedReader bufferedReader = new BufferedReader(fileReader); List<Double> lines = new ArrayList<Double>(); String line = null; while ((line = bufferedReader.readLine()) != null) { lines.add(Double.parseDouble(line)); } bufferedReader.close(); return lines.toArray(new Double[lines.size()]); } } This is my code, but when I run it I get [Ljava.lang.Double;@35960f05 …

Member Avatar
Member Avatar
+0 forum 3

hello everyone ,, have a look on the program really difficult for me to understand the concept please help

Member Avatar
Member Avatar
+0 forum 1

Alright so my problem is I am getting an error that says undefined reference to all of my functions related to DoubleLinked, DoubleLinked<string> dict, dict.add, etc. If anyone knows why that would be great. Thank you. Oh and if i add () to DoubleLinked<string> dict then i just have undefined reference errors to add and contains. #include <iostream> #include "DoubleLinked.h" #include "Node.h" #include <fstream> #include <vector> using namespace std; int main() { cout << "Hello" << endl; string st = "hello"; DoubleLinked<string> dict; vector <string> phrase; vector <string> Wrong; dict.add(st); ifstream fin; fin.open("check.txt"); string word; int c = 0; while(fin …

Member Avatar
Member Avatar
+0 forum 13

Here is code, which you can play with before installing and using the [superior blist package from pypi](http://pypi.python.org/pypi/blist/). I did it as therapy after doing programming test answer using zillion of setters and getters. Motivation is basically to show why you should use properties after you need them and attribute access before that. The function of before and after links is exchangable, so you can do reversing of directions of double linked list by just sweeping through list and toggling the flag. If that quite a hackish feature would not be there we would not need to use property. Here …

Member Avatar
+0 forum 0

hi everyone. I want to delay the click event in a vsFlexgrid so that the double click event will run 1st. I used a timer for the delay in the click event and managed to get the value of the double click speed in the windows library for the timer interval. however i still cant make it work the way I want to. Its still running the click event rather than running the double click event 1st. hope you can enlighten me with this. here's my code. ''General Declaration Declare Function GetDoubleClickTime Lib "user32" () As Long ''Form Declaration Private …

Member Avatar
Member Avatar
+0 forum 5

I have an assignment to create 2 arrays. One holding Student names, one holding their grades. They then have to be sorted using BubbleSort, so that their grades are in descending order. I have created the first part of it, that allows me to put in their grades, and I was able to succesfully sort it using BubbleSort. I ran into a problem when I realized the professor wanted it as Doubles (I had previously had it set as Ints) and now even though I think I changed all instances of Int to Double I'm still getting an error saying …

Member Avatar
Member Avatar
+0 forum 3

My teacher wants me to write a function called double cos(float); to compute the cos of an angle (given in radians) using the Taylor series shown. Your function should find the value of the cos for ANY angle (preferred) or at least angles up to 2 PI (Hint: if you can do the later, the former should be easy) to a precision of 4 decimal places (within 0.00005). You should put the function cos() in the file called trig.c. You can use the function pos_power() in your exponent.c from Lab 6 and Hw 4, and you should write functions for …

Member Avatar
Member Avatar
+0 forum 5

Hi everyone, I have a little problem with my code right now. For a project, we are to create a snack machine with cookies and mints using a GUI. We are given nickels, dimes, and quarters to enter in. The problem is when I enter in 1 nickel and 6 dimes, it doesnt work. It also doesnt work when I input 7 nickels and 3 dimes. These are the 2 combinations out of all that I tried that doesnt work(I believe I tried all possible combinations). Below are snippets of my code. package proj3; import java.awt.Color; import java.util.ArrayList; public class …

Member Avatar
+0 forum 0

I need help with this http://codepad.org/FNUci22s I am posting the ling of code pad because it has a way to execute it, so long story short. I use two different functions seno, sen (both for sin). When using the printf and adressing both to compare results I get from the seno function the correct result(sin(45)=0.70710) but the moment I remove the other function from the printf i get "nan". Funcitons dont depend from each other.

Member Avatar
Member Avatar
+0 forum 2

Hi, I'm writing a simple program that runs a vending machine. I thought I had everything working fine untill I messed around with the money input some more. In my program I obviously compare money values and check to make sure the values match up exactly to buy an item. It works under almost every case, but I have found some cases where I get an anomalous decimal value that throws off the comparison of the double values. Here is my code and output from testing within the money class itself. public class Money { private static final double NICKEL_AMMNT …

Member Avatar
Member Avatar
+0 forum 3

hello everybody; i have a problem, i want to convert a string which is an Equation to double, in order to use each part which is seprate by + or - ; how can i do that? thanks a lot for your helps.

Member Avatar
Member Avatar
+0 forum 3

Hi all, I implemented a C program using my mac book. Now, my client wants to migrate to windows OS (MinGW). Program does many calculation using long double: on mac it works fine, otherwise on winz doesn't. I read on internet the problem is that long double type is supposed to be a double type in WinZ, because it is no supported. Making sizeof of double and long double, I obtain: MAC DOUBLE=8, LONG DOUBLE=16 WINZ DOUBLE=8, LONG DOUBLE=12 Is there a solution or a workaround? How can I "force" the use of long double or its simulation? Sorry for …

Member Avatar
Member Avatar
+0 forum 4

Hi, I'm working on a quick sort for double linked list. All work except the first item. I don't know what is wrong. Can u plz help me find the error? Here is my code. dlist_t* quick_sort(dlist_t* list) { dlnode_t *tnode = NULL, *first = NULL, *last = NULL; first = list->head; last = list->foot; tnode = list->head; printf("Before Sort="); while (tnode != NULL) { printf(" %d ", *((int *) tnode->data)); tnode = tnode->next; } printf("\n\n"); quick_sorting(list, first, NULL); return list; } void quick_sorting(dlist_t *list, dlnode_t *less, dlnode_t *greater) { dlnode_t *tnode= NULL, *pivot = NULL, *i, *next, *temp = …

Member Avatar
Member Avatar
+0 forum 2

I am generating the sequence 1,3,8,22,60,.... upto 10^9 the term mod of 10^9+7; However my code is giving inaccurate answers for large value of n. The formula I am using is ((1+Q)^(n+1)-(1-Q)^(n+1))/(4*Q) Here Q is sqrt (3) Here is my code.Can someone point out the error in the code or any ways to remove this problem. Any help will be highly appreciated. #include <iostream> #include<stdio.h> #define big long long int #define foo(b) static_cast<big>(b) big ro(long double x) { if(x-(big)x>=0.5) { return x+1; } else return x; } big m=1000000007; long double Q=1.7320508075688772935274463415058723669428052538103806; using namespace std; long double mod(long double a,big …

Member Avatar
Member Avatar
+0 forum 1

Hi, below is my code for an android app I am developing, I was wondering how I can pass the value of pos from the array adapter to another activity through intent? What I would like is for the code in the next activity to be performed based on the value of the array's position from this file. I understand I have to use putExtras, but I don't understand how exactly to pass this value with the return type of onItemSelected being void. public class App2Activity extends Activity { Button button1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main2); Spinner …

Member Avatar
Member Avatar
+0 forum 3

The End.