Search Results

Search found 111 results on 5 pages for 'decimals'.

Page 1/5 | 1 2 3 4 5  | Next Page >

  • Rails Pretty URL with Decimals

    - by Kevin Sylvestre
    I have a rails application that allows searches using longitude and latitude. I have added a 'pretty' route with: map.connect 'stores/near/:longitude/:latitude', :controller => 'stores', :action => 'index' This works for integer latitude and longitude values (http://localhost:3000/stores/near/-88/49) but fails for decimal values (http://localhost:3000/stores/near/-88.341/49.123) giving: Routing Error No route matches "/stores/near/-88/49.0" with {:method=>:get} Any ideas how to use pretty URLs in rails with decimals?

    Read the article

  • linux shell utils: convert a list of hex to list of decimals

    - by osgx
    Hello How can I convert a file with a lot hex numbers into the decimal? Example: file1 0x59999 0x5acdc 0xffeff I want to start $ cat file1 | util | cat file2 and get file2 with smth like 1021489 1249230 3458080 (numbers in example output are random, as I cant convert so long hex to dec) Upd: perl : perl -pe '$_=hex;$_.="\n"'. Can anybody do it better? The real task is a sorting of hex numbers.

    Read the article

  • How to format float to 2 decimals in objective C

    - by iamdadude
    I have a string that I'm converting to a float that I want to check for values in an if statement. The original float value is the iPhone's trueHeading that is returned from the didUpdateHeading method. When I convert the original float to a string using @"%.2f" it works perfectly, but what I'm trying to do is convert the original float number to the same value. IF I just convert the string to [string floatValue] I get the same original float number, and I don't want that. To make it short and simple, how do I take an existing float value and just get the first 2 decimals?

    Read the article

  • MySQL storing negative and positive decimals

    - by Shishant
    Hello, I want to be able to store -11.99 and +11.99 kind of values in mysql db I am thinking of decimals instead of varchar. But reading mysql site I found out that its incompatible with older versions of mysql As a result of the change from string to numeric format for DECIMAL storage, DECIMAL columns no longer store a leading + or - character or leading 0 digits. Before MySQL 5.0.3, if you inserted +0003.1 into a DECIMAL(5,1) column, it was stored as +0003.1. As of MySQL 5.0.3, it is stored as 3.1. For negative numbers, a literal - character is no longer stored. Applications that rely on the older behavior must be modified to account for this change. So what should be the data type, If I have to give up varchar and make it compatible with older versions too?

    Read the article

  • Rounding Decimals to whole numbers

    - by USDblades
    I was looking around and could not find exactly what I was looking for. I want to round all my numbers up to the whole number. Example: 5.9 would be 6 5.5 would be 6 5.1 would be 6 5.000001122 would be 6 5.0 would be 5 I was thinking if I put them into ints that would get rid of the decimal but it did not look right as the decimals were just dropping off. Am I correct here? So I thought about just doing that then adding 1 to the final result which would fix about 99% of the problem but if my result is 5 I do not want to add 1 to it. How would I go about fixing this issue I have?

    Read the article

  • Decimal point removed from decimals in a Serialized XML

    - by MiguelM
    I'm using XmlSerializer with classes created from a xsd using xsd.exe. It has worked fine for months. Now I'm receiving reports that in some cases the created xml file has all decimals serialized without a decimal point, e.g. 123.45 is serialized as 12345. I haven't been able to reproduce the problem, but I'm suspecting it may be related to localization. This is my first C# project, so I may be overlooking something basic. Could localization cause this problem? How can I make the serialization process locale independent? Any idea of something else that could cause this problem?

    Read the article

  • convert javascript number to css value -- maximum number of trailing decimals

    - by philipp
    I am about to have some fun with the css transform matrix and javascript. At the moment everything is cool, except when a number becomes something like 0.000034e3344 after the to string conversion. Than the transform does not work. So I know that there is the Number.toFixed() method which actually solves the problem, but i ask myself how many trailing decimals make sense. So what is the highest value i can pass to the toFixed() method to get the most precise results? EDIT::: the exact number output was: 9.685539407532573e-20

    Read the article

  • Computed width with decimal values in Firefox, but without decimals in Webkit

    - by jävi
    Hello one more time! I have a strange problem working with HTML,CSS in different browsers: Firefox 3.6 and Webkit browsers (Chrome & Safari). My HTML looks like this: <div class="ln-letters"> <a href="#" class="all">ALL</a> <a href="#" class="a">A</a> <a href="#" class="b">B</a> <a href="#" class="c">C</a> </div> And my CSS is... .ln-letters a { font-family: 'Lucida Grande'; font-size:14px; display:block; float:left; padding:0px 7px; border-left:1px solid silver; border-right:none; text-decoration:none; } So as you can guess, each anchor gets a different width depending on its inner text. For example the first element with the text 'ALL' will be bigger (more width) than the others. Now the problem is that in Firefox (using Firebug) I can see that the computed width for the first element is 26.5667px, while in Chrome (using Chrome's developer tools) the computed width for the same element is exactly 27px. Therefore the div.ln-letters ends with different widths in each browser and that is causing me some troubles. Question is: there is any workaround to avoid Firefox computing decimal values? Or the opposite: to force Chrome to compute decimal values? Thank you in advance!

    Read the article

  • Convert time to decimals in .net

    - by henrico
    Is there an easy way to present time (hh:mm) as a decimal value? Example, 01:08 should become 1,13. I have an asp:textbox masked (ajax) as time with the mask format "99:99". Next to this box I need to present the entered value as decimal. <asp:TextBox ID="time" runat="server" /> hh:mm ([time in decimal format]) <ajaxToolkit:MaskedEditExtender runat="server" Mask="99:99" TargetControlID="time" MaskType="Time" />

    Read the article

  • EXCEL import to sql returning NULL for decimals when in VARCHAR data type

    - by Daniel
    Hi, I am working on a peice of software which has expodentially grown over the last few years and the database needs to be regularly updated. Customers are providing us with data now on large spreadsheets which we format and will start importing into the database. I am using the Import and Export Data (32-bit) Wizard. One column in the database contains values like '1.1.1.2' etc and i am importing them in as a Varchar as that is the data type in the database. However, for values like '8.5', 'NULL' is getting imported insead. It only occurs when there is one decimal point. Is this a formatting error with excel or is it the wrong datatype?

    Read the article

  • Javascript function returning number with two decimals...?

    - by muzzledBYbrass
    I have a function to return points along a line and my return comes back with two decimal points...? For example, a return of my variable px will be something like -88.4029.032940598. vx is the x vector and mult is the distance of the line plus distance to calculate the point. Here is the operation that is returning these values: var mult = parseFloat(mag + theUnit); var px = coord_one.x_point + (vx * mult); console.log(px); Never have seen this before- I appreciate any and all help!

    Read the article

  • How should 4 decimals places behave, being simple yet powerful

    - by vener
    I have a UI question that troubled me on the best method to handle 4 decimal places for prices. In an table already cramped full of data, I would want to simplified the interface to make it not so cluttered. The actual current UI is shown below. http://i41.tinypic.com/bg5tub.jpg The problem is, for a unit price/units/D.Price and Dis.(Discount) to have 4 decimal places ($0.3459) is quite rare but it still happens (5 in 100 entries). This will result a lot of junk decimal places, cluttering up the interface. What is the best solution to this problem? In short, I want to declutter it yet maintain the precision. Note: This is web app

    Read the article

  • Runtime error in C code (strange double conversion)

    - by Miro Hassan
    I have a strange runtime error in my C code. The Integers comparison here works fine. But in the Decimals comparison, I always get that the second number is larger than the first number, which is false. I am pretty new to C and programming in general, so this is a complex application to me. #include <stdio.h> #include <stdbool.h> #include <stdlib.h> int choose; long long neLimit = -1000000000; long long limit = 1000000000; bool big(a,b) { if ((a >= limit) || (b >= limit)) return true; else if ((a <= neLimit) || (b <= neLimit)) return true; return false; } void largerr(a,b) { if (a > b) printf("\nThe First Number is larger ..\n"); else if (a < b) printf("\nThe Second Number is larger ..\n"); else printf("\nThe Two Numbers are Equal .. \n"); } int main() { system("color e && title Numbers Comparison && echo off && cls"); start:{ printf("Choose a Type of Comparison :\n\t1. Integers\n\t2. Decimals \n\t\t I Choose Number : "); scanf("%i", &choose); switch(choose) { case 1: goto Integers; break; case 2: goto Decimals; break; default: system("echo Please Choose a Valid Option && pause>nul && cls"); goto start; } } Integers: { system("title Integers Comparison && cls"); long x , y; printf("\nFirst Number : \t"); scanf("%li", &x); printf("\nSecond Number : "); scanf("%li", &y); if (big(x,y)) { printf("\nOut of Limit .. Too Big Numbers ..\n"); system("pause>nul && cls") ; goto Integers; } largerr(x,y); printf("\nFirst Number : %li\nSecond Number : %li\n",x,y); goto exif; } Decimals: { system("title Decimals Comparison && cls"); double x , y; printf("\nFirst Number : \t"); scanf("%le", &x); printf("\nSecond Number : "); scanf("%le", &y); if (big(x,y)) { printf("\nOut of Limit .. Too Big Numbers ..\n"); system("pause>nul && cls") ; goto Decimals; } largerr(x,y); goto exif; } exif:{ system("pause>nul"); system("cls"); main(); } }

    Read the article

  • Best way to store sales tax information

    - by Seph
    When designing a stock management database system (sales / purchases) what would be the best way to store the various taxes and other such amounts? A few of the fields that could be saved are: Unit price excluding tax Unit price including tax Tax per item Total excluding tax (rounded to 2 decimals) Total including tax (rounded to 2 decimals) Total tax (rounded to 2 decimals) Currently the most reasonable solution so far is storing down (roughly) item, quantity, total excluding tax (rounded) and the total tax (rounded). Can anyone suggest some better way of storing this details for a generic system? Also, given the system needs to be robust, what should be done if there were multiple tax values (eg: state and city) which might need to be separated, in this case a separate table would be in order, but would it be considered excessive to just have a rowID and some taxID mapping to a totalTax column?

    Read the article

  • Why do you need float/double?

    - by acidzombie24
    I was watching http://www.joelonsoftware.com/items/2011/06/27.html and laughed at Jon Skeet joke about 0.3 not being 0.3. I personally never had problems with floats/decimals/doubles but then I remember I learned 6502 very early and never needed floats in most of my programs. The only time I used it was for graphics and math where inaccurate numbers were ok and the output was for the screen and not to be stored (in a db, file) or dependent on. My question is, where are places were you typically use floats/decimals/double? So I know to watch out for these gotchas. With money I use longs and store values by the cent, for speed of an object in a game I add ints and divide (or bitshift) the value to know if I need to move a pixel or not. (I made object move in the 6502 days, we had no divide nor floats but had shifts). So I was mostly curious.

    Read the article

  • What is wrong with this Anonymous Object Initializate Syntax?

    - by Ramiz Uddin
    What is wrong with this Anonymous Object Initialize syntax? If (Not row Is Nothing) Then Dim info As New CultureInfo(Conversions.ToString(row.Item("cultureId"))) With { _ .NumberFormat = New With {.CurrencySymbol = Conversions.ToString(row.Item("symbol")), .CurrencyGroupSeparator = Conversions.ToString(row.Item("thousSep")), .CurrencyDecimalSeparator = Conversions.ToString(row.Item("thousSep")), .CurrencyDecimalDigits = Conversions.ToInteger(row.Item("decimals")), .NumberGroupSeparator = Conversions.ToString(row.Item("thousSep")), .NumberDecimalSeparator = Conversions.ToString(row.Item("thousSep")), .NumberDecimalDigits = Conversions.ToInteger(row.Item("decimals"))}} } hashtable.Add(key, info) End If It is a syntax error or object initialization type casting issue. Thanks.

    Read the article

  • converting factored number to decimal in MS SQL

    - by LS
    I need to convert a number which gives decimals in factored format in to decimals, i.e. 11.16 is 11.5 in decimal. This is because 16 is in base of 32 and 11.16 should be read as 11+16/32 = 11.5 I get 11.16 as a string and I need to change it to 11.5 as numeric in MS SQL(2005) database. Any shorter way of doing this rather than splitting strings,converting to numerics,maths,convert to string, concatenate and then convert to numeric?

    Read the article

  • How to temporarily replace one primitive type with another when compiling to different targets in c#

    - by Keith
    How to easily/quickly replace float's for doubles (for example) for compiling to two different targets using these two particular choices of primitive types? Discussion: I have a large amount of c# code under development that I need to compile to alternatively use float, double or decimals depending on the use case of the target assembly. Using something like “class MYNumber : Double” so that it is only necessary to change one line of code does not work as Double is sealed, and obviously there is no #define in C#. Peppering the code with #if #else statements is also not an option, there is just too much supporting Math operators/related code using these particular primitive types. I am at a loss on how to do this apparently simple task, thanks! Edit: Just a quick comment in relation to boxing mentioned in Kyles reply: Unfortunately I need to avoid boxing, mainly since float's are being chosen when maximum speed is required, and decimals when maximum accuracy is the priority (and taking the 20x+ performance hit is acceptable). Boxing would probably rules out decimals as a valid choice and defeat the purpose somewhat. Edit2: For reference, those suggesting generics as a possible answer to this question note that there are many issues which count generics out (at least for our needs). For an overview and further references see Using generics for calculations

    Read the article

1 2 3 4 5  | Next Page >