473,378 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

working with array with floats

I have read a file with the file() command and it contains numbers, numbers
that are larger than 2^32 and now I wonder, will this be a problem if I do
arithemtcis, or is there some easy way to force it to use consider the
array as floatingpoint numbers?
--
I didn't know sci.bio.paleontology was that low traffic until I tried read
the thread "Where is everyone?" and found it to be expired.
Jan 31 '07 #1
3 1531
Rik
Gunnar G <de****@comhem.sewrote:
I have read a file with the file() command and it contains numbers,
numbers
that are larger than 2^32 and now I wonder, will this be a problem if I
do
arithemtcis,
I leave that to the people who actually learned the basics, is suspect it
might.
or is there some easy way to force it to use consider the
array as floatingpoint numbers?
You can use floatval() on a string without problems. However, depending on
how the data in that file is stored, you might want to look into the
fscanf() function.
--
Rik Wasmus
Jan 31 '07 #2
On Jan 31, 1:38 pm, Gunnar G <deb...@comhem.sewrote:
I have read a file with the file() command and it contains numbers, numbers
that are larger than 2^32 and now I wonder, will this be a problem if I do
arithemtcis, or is there some easy way to force it to use consider the
array as floatingpoint numbers?
No worries! PHP will automatically convert types for you to hold the
number you want.
>
--
I didn't know sci.bio.paleontology was that low traffic until I tried read
the thread "Where is everyone?" and found it to be expired.

Feb 1 '07 #3
On Wed, 31 Jan 2007 11:38:42 -0800, Gunnar G <de****@comhem.sewrote:
I have read a file with the file() command and it contains numbers,
numbers
that are larger than 2^32 and now I wonder, will this be a problem if I
do
arithemtcis, or is there some easy way to force it to use consider the
array as floatingpoint numbers?

Although PHP's dynamic typing should handle this properly, it might be
useful to convert the string to an unsigned int with sprintf, if you run
into issues:

/* maybe pretend we're looping */
$uintArray[] = sprintf('%u', trim($currentLine)); // this way, huge ints
won't become negative

This is useful when you are converting IPs to longs.

--
Curtis, http://dyersweb.com
Feb 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Asfand Yar Qazi | last post by:
Hi, I've got this class, you see: class Vec4 { Vec4(); ... float data; float& x;
2
by: Daniel Mori | last post by:
Hi, Im hoping someone can give me some advice. Im doing some development using VS Whidbey 2005 beta 1. Im about to implement some highly time critical code related to a managed collection of...
3
by: Lars Grobe | last post by:
Hi, first hello, I am new to the list, and I guess my question will show that clearly. I want to use some vector operations (at the moment altivec) in existing code. It is a raytracing-based...
9
by: Gregory.A.Book | last post by:
I am interested in converting sets of 4 bytes to floats in C++. I have a library that reads image data and returns the data as an array of unsigned chars. The image data is stored as 4-byte floats....
7
by: SpreadTooThin | last post by:
I have some code... import array a = array.array('d') f = open('file.raw') a.fromfile(f, 10) now I need to convert them into floats (32 bit...) what do i do?
3
by: Andrew Gentile | last post by:
Hello, I am trying to write a function which takes several floats as inputs, then returns 1x6 array of floats. I normally program in Matlab, and I am often confused by C. It seems that this...
14
by: mast2as | last post by:
Hi everyone, I am trying to implement some specs which specify that an array of parameter is passed to a function as a pointer to an array terminated by a NULL chatacter. That seemed fairly easy...
0
by: jeff_rowa | last post by:
Hi guyz, Could anyone please tell me how can I convert an array of floats to a string? I know that I can use this code to convert one float to a string but what is the best way for an array of...
33
by: Adam Chapman | last post by:
Hi, Im trying to migrate from programming in Matlab over to C. Im trying to make a simple function to multiply one matrix by the other. I've realised that C can't determine the size of a 2d...
9
by: John [H2O] | last post by:
Hello, I'm trying to do the following: datagrid = numpy.zeros(360,180,3,73,20) But I get an error saying that the dimensions are too large? Is there a memory issue here? So, my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.