similar to: Formatting a float with a set number of decimals

Displaying 20 results from an estimated 600 matches similar to: "Formatting a float with a set number of decimals"

2007 Nov 27
3
Disappearing decimals... please help!
Maybe it''s all in my head, but I''m having the strangest little issue ever. My pricetags in my rails app are always whole numbers. Rails seems to completely ignore my decimal input. So as a consequence, 10.41 becomes 10.00, always. Here''s some worthwhile stuff: within my 004_create_products.rb file: :price, :decimal, :percision => 2, :default => 0 And calling
2006 Jan 27
3
Formatting Data in rhtml
Is there a simple way to format your data in the .rhtml file? I come from a PHP/Smarty background, and in the templates, I''ve used what is called "modifiers" to format data. {$price|currency_format} # displays in currency format {$description|truncate:"100"} # Truncates the description after 100 characters It seems like the template (rhtml) would be the ideal
2006 Jul 26
7
Delete_all causes a deadlock on MSSQL database ???
Hi all, When i use the ''delete_all'' function to remove a few rows from my database, it causes a deadlock on the sql server. The delete seems to be successful, it then redirects to the ''view'' page, and the record does appear to be deleted as far as the ''view'' rails page shows. BUT if i go into sql query analyser, i can''t do a
2012 Oct 12
3
Autofilling a large matrix in R
I wish to create a matrix of all possible percentages with two decimal place percision. I then want each row to sum to 100%. I started with the code below with the intent to then subset the data based on the row sum. This works great for 2 or 3 columns, but if I try 4 or more columns the number of rows become to large. I would like to find a way to break it down into some kind of for loop, so
2006 Feb 20
2
Problem with flash[:notice] appearing twice
In my save function in my (ajax!!!) controller, i''ve got a bit like this: if ... flash[:notice] = ''NOT SAVED: This month is locked'' render :partial => ''edit'' else save it... redirect to ''show'' action.... ... If i try to save an entry for a locked month, it correctly brings me back to my edit action with the
2006 Jan 17
2
How to run direct sql
How can i run and get the value from the following sql: select avg(my_field) from my_table where which_year=''0506'' and which_week <= 21 and my_foreign_key_id=10 cheers -- Posted via http://www.ruby-forum.com/.
2005 Dec 19
3
Trying to make an app helper
Any ideas with fixing this? Doesn''t work properly, although it doesn''t throw any runtime errors. # Methods added to this helper will be available to all templates in the application. module ApplicationHelper def options_for_months(selected_month)
2005 Dec 19
3
Where to put code - app controller, or app helper?
I have a function i want to be used in both views and controllers: def year_to_fiscal_year(year) # converts, say, an integer 2003 into ''0304'' year.to_s[2,2] << (year+1).to_s[2,2] end Where should i put it ? -- Posted via http://www.ruby-forum.com/.
2005 Dec 20
2
Designing a data-entry screen
Here''s what i''m trying to do: Have 3 dropdowns up the top of a page, being: year, month, department, and group. Also a button underneath that called refresh. When you click refresh, it finds the 1 row of data from the database for that year/month/dept/group and populates the fields into a set of textboxes below. Then you can edit what is in those textboxes, and click a
2006 Jan 24
4
How to filter an activerecord find_all...
I have a nice hierarchical table structure like this: divisions has_many groups groups belongs_to division has_many subgroups subgroups belongs_to group has_many units units belongs_to subgroup I have a report which is based on units, but i want to be able to filter the units by which subgroup, or which group, or which division. I also want to sort them by division.name,then group.name,
2008 Nov 10
1
cant boot after installation of centos 5
Hi all, I'm having problems with the installation of CentOS 5 for i386 to my Dell Percision T4500 Workstation. The installation run just fine. The installation DVD had been tested before installation. After installation, the installer ask me to reboot. after reboot, when the msg for LVM saying detection of my LVMs, 1 or 2 lines after that my monitor turned off, but i believed the cpu is still
2009 Aug 03
5
Decimal datatype and trailing zeros
Hello I''ve encountered a little problem with zeros using the decimal data type Specifying a scale of 3 and inserting a number with 3 zeros after the point (for example 12345.000) it gets correctly stored in the database, but rails insists to show me the number only with the first zero after the point (12345.0) There is a way to tell rails to not truncate at the first zero?
2004 Aug 06
1
Intel libraries
Warning: newbie post I've scanned the archives and found some discussion of porting some code so it's integer based as opposed to floating point based. Has anyone looked at using Intel's Integrated Performance Primitives or their Math Kernel Library in an effort to optimize the code across all x86/XScale processors? IPP: http://www.intel.com/software/products/ipp/ipp30/ KML:
2006 Mar 15
2
Using form_remote_tag, setting the form name
I''m using form_remote_tag like this: <%= form_remote_tag \ :update => "div_id_dataentry_bottom_ajax", :loading => "document.getElementById(''wait'').innerHTML=''Loading...'';", :url => { :action => "dataentry_bottom_edit" } %> And it makes this code: <form
2005 Dec 21
3
How to make a drop-down automatically submit an AJAX form
Hi, I know that to make a dropdown box automatically submit when you change the value, you do this: <select ..... onchange="this.form.submit();"> BUT i''ve got an ajax form, and if i do the above trick, it simply reloads the ajax partial into the whole screen, rather than into the div where it is meant to go. I''ve already got it all working so that if you click
2005 Dec 22
2
Accessing an instance variable by its name (as a string)
Hi (again!) I have a function which gets passed the name of an instance variable, and spits its out all nicely formatted. Just wondering, how do i access the variable, when all i have is its name stored as a string? So far i''ve got this code, but it looks horrible. Is there a better way? eval("@" << inst_var_name << "." << field_name <<
2011 Apr 13
1
Decimals in R/SQL
Hello, When I am writing in sqldf or RSQLite I lose the decimals in my matrix. The only way I can get decimals is by multiplying by 1.00000, etc. I have tried manipulating the options, but it is only effective once I multiply by 1.0000. I appreciate any suggestions! Thanks! Example: z <- sqldf ("select ST, SUM(AGEP*PWGTP)*1.000000000/SUM(PWGTP)*1.00000000000000 as wgtage from ss09
2003 Apr 22
1
read.table and decimals
Dear, We are trying to read an asciifile using the read.table() function and discovered that only 4 decimals are read. Any idea how to get more decimals? Kris -- ------------------------------------------------------------------------ http://perswww.kuleuven.ac.be/~u0027178/VCard/mycard.php?name=krisn ------------------------------------------------------------------------ Minds are
2006 Apr 08
1
Entering numbers with decimals
Hello list, I'm just getting started with R, and I'm trying to determine how R treats large numbers that have decimals. Take the following two examples: > x <- c(999999999999999.9) > sprintf("%.5f",x) [1] "999999999999999.87000" > y <- c(9999999999999999.9) > sprintf("%.5f",y) [1] "10000000000000000.00000" I realize that I have
2008 Jan 19
1
Decimals are being converted to Bigdecimals!!!!!
Hi all, I''m working on a financial app, and have set up some columns in my tables as decimals with precision => 8 and scale => 2. My migration looks like: change_column :lineitems, :price, :decimal, :precision => 8, :scale => 2 change_column :payments, :amount, :decimal, :precision => 8, :scale => 2 I''ve run the migration and restarted the server. I