Search Results

Search found 379 results on 16 pages for 'floats'.

Page 9/16 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • What's the easiest way to parse numbers in clojure?

    - by Rob Lachlan
    I've been using java to parse numbers, e.g. (. Integer parseInt numberString) Is there a more clojuriffic way that would handle both integers and floats, and return clojure numbers? I'm not especially worried about performance here, I just want to process a bunch of white space delimited numbers in a file and do something with them, in the most straightforward way possible. So a file might have lines like: 5 10 0.0002 4 12 0.003 And I'd like to be able to transform the lines into vectors of numbers.

    Read the article

  • How can I encode four unsigned bytes (0-255) to a float and back again using HLSL?

    - by Statement
    Hello! I am facing a task where one of my hlsl shaders require multiple texture lookups per pixel. My 2d textures are fixed to 256*256, so two bytes should be sufficient to address any given texel given this constraint. My idea is then to put two xy-coordinates in each float, giving me eight xy-coordinates in pixel space when packed in a Vector4 format image. These eight coordinates are then used to sample another texture(s). The reason for doing this is to save graphics memory and an attempt to optimize processing time, since then I don't require multiple texture lookups. By the way: Does anyone know if encoding/decoding 16 bytes from/to 4 floats using 1 sampling is slower than 4 samplings with unencoded data?

    Read the article

  • Microsoft SQL Server 2005 - using the modulo operator

    - by cc0
    So I have a silly problem, I have not used much SQL Server before, or any SQL for that matter. I basically have a minor mathematical problem that I need solved, and I thought modulo would be good. I have a number of dates in the database, but I need them be rounded off to the closest [dynamic integer] (could be anything from 0 to 5000000) which will be input as a parameter each time this query is called. So I thought I'd use modulo to find the remainder, then subtract that remainder from the date. If there is a better way, or an integrated function, please let me know! What would be the syntax for that? I've tried a lot of things, but I keep getting error messages like integers/floats/decimals can't be used with the modulo operators. I tried casting to all kinds of numeric datatypes. Any help would be appreciated.

    Read the article

  • Reading ASCII numbers using "D" instead of "E" for scientific notation using C

    - by Arrieta
    Hello, I have a list of numbers which looks like this: 1.234D+1 or 1.234D-02. I want to read the file using C. The function atof will merely ignore the D and translate only the mantissa. The function fscanf will not accept the format '%10.6e' because it expects an E instead of a D in the exponent. When I ran into this problem in Python, I have up and merely used a string substitution before converting from string to float. But in C, I am sure there must be another way. So, how would you read a file with numbers using D instead of E for scientific notation? Notice that I do not mean how to read the strings themselves, but rather how to convert them to floats. Thanks.

    Read the article

  • What's the best way to read/write array contents from/to binary files in C#?

    - by Eric
    I would like to read and write the contents of large ( 2GB), raw volume files (e.g. MRI scans). These files are just a sequence of e.g. 32 x 32 x 32 floats so they map well to 1D arrays. I would like to be able to read the contents of the binary volume files into 1D arrays of e.g. float or ushort (depending on the data type of the binary files) and similarly export the arrays back out to the raw volume files. What's the best way to do this with C#? Read/Write them 1 element at a time with BinaryReader/BinaryWriter? Read them piece-wise into byte arrays with FileStream.Read and then do a System.Buffer.BlockCopy between arrays (keeping in mind that I want 2GB arrays)? Write my own Reader/Writer?

    Read the article

  • Do you know a good and efficient FFT?

    - by yan bellavance
    Hi, I am trying to find a very fast and efficient Fourier transform (FFT). Does anyone know of any good ones. I need to run it on the iPhone so it must not be intensive. Instead, maybe you know of one that is wavelet like, i need frequency resolution but only a narrow band (vocal audio range up to 10khz max...even 10Khz might be too high). Im thinking also of truncating this FFT to keep the frequency resolution while eliminating the unwanted frequency band. This is for an iphone ...I have taken a look at the FFT in Aurio touch but it seems this is an int FFT but my app uses floats.....would it give a big performance increase to try and adapt program to an int FFT or not(which i really dont feel like doing...plus aurio touch uses a radix 2 FFT which is not that great).

    Read the article

  • Objective C Insanity -- simple assignement to a single float variable results in {{{CRAZY}}} values

    - by morgancodes
    memberA is defined in the header of ClassA. memberB is defined in the header of ClassB. ClassB is a subclass of ClassA Inside an instance of ClassB, setting memberA via simple assignment: memberA = 0.05 ...also changes memberB, but to a crazy number -- 1028443341. Additionally, assigning 0.05 to memberA results in memberA showing up in the debugger as 5.33083531e-38. Both variables are floats, neither is a pointer. I'm almost certianly making some noob mistake, but I don't have any clue what it might be. What sort of screw-up might make it so assigning a value to one variable results in crazy values appearing in two variables? I can give more details or real code, but figured I'd keep it simple to start with in case it's an obvious problem/solution.

    Read the article

  • Converting raw bytes into audio sound

    - by Afro Genius
    In my application I inherit a javastreamingaudio class from the freeTTS package then bypass the write method which sends an array of bytes to the SourceDataLine for audio processing. Instead of writing to the data line, I write this and subsequent byte arrays into a buffer which I then bring into my class and try to process into sound. My application processes sound as arrays of floats so I convert to float and try to process but always get static sound back. I am sure this is the way to go but am missing something along the way. I know that sound is processed as frames and each frame is a group of bytes so in my application I have to process the bytes into frames somehow. Am I looking at this the right way? Thanx in advance for any help.

    Read the article

  • Power Law distribution for a given exponent in C# using MathNet

    - by Eric Tobias
    Hello! I am currently working on a project where I need to generate multiple values (floats or doubles preferably) that follow a power law distribution with a given exponent! I was advised to use the MathNet.Iridium library to help me. The problem I have is that the documentation is not as explicit as it should be if there is any! I see multiple distributions that fit the general idea of the power law distribution but I cannot pinpoint a good distribution to use with a certain exponent as a parameter. Does anybody have more experience in that matter and could give me some hints or advice?

    Read the article

  • Caching view-port based Geo-queries

    - by friism
    I have a web app with a giant Google Map in it. As users pan and zoom around on the map, points are dynamically loaded through AJAX call which include the viewport bounds (NE and SW corner coordinates) and some other assorted parameters. How do I cache these request for points? The problem is that the parameters are highly variable and (worst) not discrete i.e. floats with a lots of decimal places. I'm using ASP.NET-MVC/C#/LINQ2SQL/SQL-Server but the problem is not tied to that platform. This is the signature of the the relevant method: [AcceptVerbs(HttpVerbs.Post)] public JsonResult Data(string date, string categories, string ne_lat, string ne_lng, string sw_lat, string sw_lng)

    Read the article

  • simple div containing span won't size correctly

    - by brad
    I thought I was pretty knowledgeable about CSS but this simple problem baffles me. <div><span>sample text</span></div> results in the div's height being smaller than the height of the span if the span has padding. I realize that there are ways to use "float" to make the div size correctly, but floats always seem to introduce undesired side effects. Isn't there a clean simple way to tell the div to size to fit its contents? Seems pretty basic to me. Maybe I'm missing something.

    Read the article

  • Are Sphinx & thinking_sphinx really stable? Not indexing Columns

    - by seb
    I'm encountering strange behaviour from thinking_sphinx/sphinx. My define_index block is about 100 lines, so quite a lot of columns i'm indexing. For full-text searching I only need about 10 attributes, for sorting and filtering I have another approximately 50 columns, mostly floats and integers. By filtering I mean using the "with" or "without" options. Searching does not really work consistently. All of a sudden, one attribute fails to filter. Or if I add a new one, it does not work. Only after a lot of tinkering it suddenly starts working. I cannot really reproduce it. Steps I that sometimes lead me to success where: rm -rf db/sphinx change the attribute definition e.g. has some_attribute = has some_attribute, :sortable = true or = has some_attribute, :sortable = true, :as = "some_attribute" restarting the server assigning a new :as name = has some_attribute, :as = "some_attribute_new" (yes, I did rake ts:rebuild or rake ts:in after every step) Does anybody else encounter similar problems?

    Read the article

  • Inserting multiple types into an SQLite database with Python

    - by mankoff
    I'm trying to create an SQLite 3 database from Python. I have a few types I'd like to insert into each record: A float, and then 3 groups of n floats, currently a tuple but could be an array or list.. I'm not well-enough versed in Python to understand all the differences. My problem is the INSERT statement. DAS = 12345 lats = (42,43,44,45) lons = (10,11,12,13) times = (1,2,3,4,5,6,7,8,9) import sqlite3 connection = sqlite3.connect("test.db") cursor = connection.cursor() cursor.execute( "create table foo(DAS LONG PRIMARY KEY,lats real(4),lons real(4), times real(9) )" ) I'm not sure what comes next. Something along the lines of: cmd = 'INSERT into foo values (?,?,?,?), ..." cursor.execute(cmd) How should I best build the SQL insert command given this data?

    Read the article

  • Latex two captioned verbatim environments side-by-side

    - by egon
    How to get two verbatim environments inside floats with automatic captioning side-by-side? \usepackage{float,fancyvrb} ... \DefineVerbatimEnvironment{filecontents}{Verbatim}% {fontsize=\small, fontfamily=tt, gobble=4, frame=single, framesep=5mm, baselinestretch=0.8, labelposition=topline, samepage=true} \newfloat{fileformat}{thp}{lof}[chapter] \floatname{fileformat}{File Format} \begin{fileformat} \begin{filecontents} A B C \end{filecontents} \caption{example.abc} \end{fileformat} \begin{fileformat} \begin{filecontents} C B A \end{filecontents} \caption{example.cba} \end{fileformat} So basically I just need those examples to be side-by-side (and keeping automatic nunbering of caption). I've been trying for a while now.

    Read the article

  • Import a Collada model doesn't align to pixels

    - by Dan Friedman
    Assume I have a model that is simply a cube. (It is more complicated than a cube, but for the purposes of this discussion, we will simplify.) So when I am in Sketchup, the cube is Xmm by Xmm by Xmm, where X is an integer. I then export the a Collada file and subsequently load that into threejs. Now if I look at the geometry bounding box, the values are floats, not integers. So now assume I am putting cubes next to each other with a small space in between say 1 pixel. Because screens can't draw half pixels, sometimes I see one pixel and sometimes I see two, which causes a lack of uniformity. I think I can resolve this satisfactorily if I can somehow get the imported model to have integer dimensions. I have full access to all parts of the model starting with Sketchup, so any point in the process is fair game. Is it possible? Thanks.

    Read the article

  • Manipulating and comparing floating points in java

    - by Praneeth
    In Java the floating point arithmetic is not represented precisely. For example following snippet of code float a = 1.2; float b= 3.0; float c = a * b; if(c == 3.6){ System.out.println("c is 3.6"); } else { System.out.println("c is not 3.6"); } actually prints "c is not 3.6". I'm not interested in precision beyond 3 decimals (#.###). How can I deal with this problem to multiply floats and compare them reliably? Thanks much

    Read the article

  • Why is floating point byte swapping different from integer byte swapping?

    - by CJ
    I have a binary file of doubles that I need to load using C++. However, my problem is that it was written in big-endian format but the fstream operator will then read the number wrong because my machine is little-endian. It seems like a simple problem to resolve for integers, but for doubles and floats the solutions I have found won't work. How can I (or should I) fix this? I read this as a reference for integer byte swapping: http://stackoverflow.com/questions/105252/how-do-i-convert-between-big-endian-and-little-endian-values-in-c

    Read the article

  • Two tables side by side in one column LaTeX environment

    - by Gacek
    The question is similar to this one: http://stackoverflow.com/questions/1491717/how-to-display-a-content-in-two-column-layout-in-latex but about placing two tables side by side. I have two small tables looking like that: \begin{table}[t] \begin{tabular}{|c|l||r|r||r|r|} %content goes here \end{tabular} \caption{some caption} \end{table} \begin{table}[t] \begin{tabular}{|c|l||r|r||r|r|} %content goes here \end{tabular} \caption{some caption for second table} \end{table} I have one-column document and these tables are really narrow, so I would like to display them side by side (with separate captions) insted of one under another with a lot of unused, white space. I tried to do it with this \multicols but it seems that floats (tables here) cannot be placed inside of it. Any ideas?

    Read the article

  • Latex label/ref for "fake" external figure

    - by Yannick Wurm
    Hello, some journals require each figure to be submitted in a separate document. However, they do want the figure legends to be listed in the main document. I was thus hoping to do something along these lines: \section{Figure Legends} \begin{description} \item[Figure \ref{fig:fireAntBiology}] \label{fig:fireAntBiology} bla bla ants \end{description} This would still permit to \ref the figure from the main text. However, it doesn't work (The \ref returns the number of section "Figure Legends"). The following correctly gives a different number to each "figure": \item[Figure \ref{fig:fireAntBiology}] \begin{figure} \caption{\label{fig:fireAntBiology}} \end{figure} bla bla ants However, it also places empty figure floats throughout the document. A solution should be straightforward. What am I missing? Any ideas? Thanks! yannick

    Read the article

  • What's a better choice for SQL-backed number crunching - Ruby 1.9, Python 2, Python 3, or PHP 5.3?

    - by Ivan
    Crterias of 'better': fast im math and simple (little of fields, many records) db transactions, convenient to develop/read/extend, flexible, connectible. The task is to use a common web development scripting language to process and calculate long time series and multidimensional surfaces (mostly selectint/inserting sets of floats and dong maths with rhem). The choice is Ruby 1.9, Python 2, Python 3, PHP 5.3, Perl 5.12, JavaScript (node.js). All the data is to be stored in a relational database (due to its heavily multidimensional nature), all the communication with outer world is to be done by means of web services.

    Read the article

  • Add C pointer to NSMutableArray

    - by Georges Oates Larsen
    I am writing an Objective-C program that deals with low level image memory. I am using ANSI-C structs for my data storage -- Full blown objects seem overkill seeing as the data I am storing is 100% data, with no methods to operate on that data. Specifically, I am writing a customizable posterization algorithm which relies on an array of colors -- This is where things get tricky. I am storing my colors as structs of three floats, and an integer flag (related to the posterization algorithm specifically). Everyhting is going well, except for one thing... [actual question] I can't figure out how to add pointers to an NSMutableArray! I know how to add an object, but adding a pointer to a struct seems to be more difficult -- I do not want NSMutableArray dereferencing my pointer and treating the struct as some sort of strange object. I want NSMutableArray to add the pointer its self to its collection. How do I go about doing this? Thanks in advance, G

    Read the article

  • Find next lower item in a sorted list

    - by Sebastian
    Hey guys, let's say I have a sorted list of Floats. Now I'd like to get the index of the next lower item of a given value. The usual for-loop aprroach has a complexity of O(n). Since the list is sorted there must be a way to get the index with O(log n). My O(n) approach: index=0 for i,value in enumerate(mylist): if value>compareValue: index=i-1 Is there a datatype for solving that problem in O(log n)? best regards Sebastian

    Read the article

  • Add opening and closing balance columns

    - by user1862899
    i have a table like this: StockNumber|InventoryName|Year|Month|Adj|iss|piss|Tsfr|return|rdj|rpo|xefr alb001 clinic1 2010 1 4 5 5 5 6 5 4 10 alb001 Clinic1 2010 2 10 2 2 3 3 4 4 4 alb001 Clinic1 2010 4 11 3 5 77 90 78 9 6 alb001 Clinic1 2010 5 10 2 2 3 3 4 4 4 i want to add a closing balance column which will be sum(return+rdj+rpo+xefr) - sum(adj+iss+piss+tsfr) i also want to add the opening balance column which will be the be the closing balance of the previous month. i will then calculate the current months balance as OpeningBalance + sum(return+rdj+rpo+xefr) - sum(adj+iss+piss+tsfr) = ClosingBalance NB.The Year and Month columns are floats and also want to change them to date format. i am newbie to sql and crystal reports....i want a query to help me achieve the tasks of developing a report that has the opening and closing balance columns,the opening balance being the previous closing balance.....thank you for your help....

    Read the article

  • Integers in JavaScript

    - by muntoo
    I'm a beginner to Javascript so forgive me if I sound dumb because I learned some Javascript from W3Fools (which are really difficult tutorials - they don't explain anything I want to know, but everything I probably can guess from my experience with C++). I may be switching over to MDN, but if you can recommend any other tutorials, that be great. Anyways, so here's my question: I just read a few lines of this, and apparently: Numbers in JavaScript are "double-precision 64-bit format IEEE 754 values", according to the spec. This has some interesting consequences. There's no such thing as an integer in JavaScript, so you have to be a little careful with your arithmetic if you're used to math in C or Java. I've already seen that there are few of the data types (for variables) I'm used to from C++. But I didn't expect all numbers to automatically be floats. Isn't there any way to use integers, not float? Will a future version of JavaScript support ints?

    Read the article

  • What is the best way to clear the CSS style "float"?

    - by Sam Saffron
    I'm pretty accustomed to clearing my floats by using <br style="clear:both"/> but stuff keeps on changing and I am not sure if this is the best practice. There is a CSS hack (from positioneverything) available that lets you achieve the same result without the clearing div. But... they claim the hack is a little out of date and instead you perhaps should look at this hack. But.. after reading through 700 pages of comments :) it seems there may be some places the latter hack does not work. I would like to avoid any javascript hacks cause I would like my clearing to work regardless of javascript being enabled. What is the current best practice for clearing divs in a browser independent way?

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >